Same change to the collider-related method in VoxelChunk.

This commit is contained in:
Relintai 2020-10-26 17:24:22 +01:00
parent 98155939c2
commit 851b4efb52
4 changed files with 46 additions and 46 deletions

View File

@ -502,8 +502,8 @@ void VoxelChunkDefault::update_transforms() {
}
}
for (int i = 0; i < get_collider_count(); ++i) {
PhysicsServer::get_singleton()->body_set_state(get_collider_body(i), PhysicsServer::BODY_STATE_TRANSFORM, get_transform() * get_collider_transform(i));
for (int i = 0; i < collider_get_count(); ++i) {
PhysicsServer::get_singleton()->body_set_state(collider_get_body(i), PhysicsServer::BODY_STATE_TRANSFORM, get_transform() * collider_get_transform(i));
}
if (_debug_mesh_instance != RID()) {
@ -683,13 +683,13 @@ void VoxelChunkDefault::draw_debug_mdr_colliders() {
debug_mesh_allocate();
}
for (int i = 0; i < get_collider_count(); ++i) {
Ref<Shape> shape = get_collider_shape(i);
for (int i = 0; i < collider_get_count(); ++i) {
Ref<Shape> shape = collider_get_shape(i);
if (!shape.is_valid())
continue;
Transform t = get_collider_transform(i);
Transform t = collider_get_transform(i);
shape->add_vertices_to_array(_debug_mesh_array, t);
}

View File

@ -51,11 +51,11 @@ void VoxelPropJob::phase_physics_process() {
Ref<VoxelChunkDefault> chunk = _chunk;
//TODO this should only update the differences
for (int i = 0; i < chunk->get_collider_count(); ++i) {
PhysicsServer::get_singleton()->free(chunk->get_collider_body(i));
for (int i = 0; i < chunk->collider_get_count(); ++i) {
PhysicsServer::get_singleton()->free(chunk->collider_get_body(i));
}
chunk->clear_colliders();
chunk->colliders_clear();
#ifdef MESH_DATA_RESOURCE_PRESENT
for (int i = 0; i < chunk->mesh_data_resource_get_count(); ++i) {
@ -90,13 +90,13 @@ void VoxelPropJob::phase_physics_process() {
PhysicsServer::get_singleton()->body_set_state(body, PhysicsServer::BODY_STATE_TRANSFORM, chunk->get_transform() * transform);
chunk->add_collider(transform, shape, shape->get_rid(), body);
chunk->collider_add(transform, shape, shape->get_rid(), body);
}
}
#endif
#if TOOLS_ENABLED
if (SceneTree::get_singleton()->is_debugging_collisions_hint() && chunk->get_collider_count() > 0) {
if (SceneTree::get_singleton()->is_debugging_collisions_hint() && chunk->collider_get_count() > 0) {
chunk->draw_debug_mdr_colliders();
}
#endif

View File

@ -851,7 +851,7 @@ void VoxelChunk::mesh_data_resource_clear() {
#endif
int VoxelChunk::add_collider(const Transform &local_transform, const Ref<Shape> &shape, const RID &shape_rid, const RID &body) {
int VoxelChunk::collider_add(const Transform &local_transform, const Ref<Shape> &shape, const RID &shape_rid, const RID &body) {
ERR_FAIL_COND_V(!shape.is_valid() && shape_rid == RID(), 0);
int index = _colliders.size();
@ -867,60 +867,60 @@ int VoxelChunk::add_collider(const Transform &local_transform, const Ref<Shape>
return index;
}
Transform VoxelChunk::get_collider_transform(const int index) {
Transform VoxelChunk::collider_get_transform(const int index) {
ERR_FAIL_INDEX_V(index, _colliders.size(), Transform());
return _colliders[index].transform;
}
void VoxelChunk::set_collider_transform(const int index, const Transform &transform) {
void VoxelChunk::collider_set_transform(const int index, const Transform &transform) {
ERR_FAIL_INDEX(index, _colliders.size());
_colliders.write[index].transform = transform;
}
Ref<Shape> VoxelChunk::get_collider_shape(const int index) {
Ref<Shape> VoxelChunk::collider_get_shape(const int index) {
ERR_FAIL_INDEX_V(index, _colliders.size(), Ref<Shape>());
return _colliders[index].shape;
}
void VoxelChunk::set_collider_shape(const int index, const Ref<Shape> &shape) {
void VoxelChunk::collider_set_shape(const int index, const Ref<Shape> &shape) {
ERR_FAIL_INDEX(index, _colliders.size());
_colliders.write[index].shape = shape;
}
RID VoxelChunk::get_collider_shape_rid(const int index) {
RID VoxelChunk::collider_get_shape_rid(const int index) {
ERR_FAIL_INDEX_V(index, _colliders.size(), RID());
return _colliders[index].shape_rid;
}
void VoxelChunk::set_collider_shape_rid(const int index, const RID &rid) {
void VoxelChunk::collider_set_shape_rid(const int index, const RID &rid) {
ERR_FAIL_INDEX(index, _colliders.size());
_colliders.write[index].shape_rid = rid;
}
RID VoxelChunk::get_collider_body(const int index) {
RID VoxelChunk::collider_get_body(const int index) {
ERR_FAIL_INDEX_V(index, _colliders.size(), RID());
return _colliders[index].body;
}
void VoxelChunk::set_collider_body(const int index, const RID &rid) {
void VoxelChunk::collider_set_body(const int index, const RID &rid) {
ERR_FAIL_INDEX(index, _colliders.size());
_colliders.write[index].body = rid;
}
int VoxelChunk::get_collider_count() const {
int VoxelChunk::collider_get_count() const {
return _colliders.size();
}
void VoxelChunk::remove_collider(const int index) {
void VoxelChunk::collider_remove(const int index) {
ERR_FAIL_INDEX(index, _colliders.size());
_colliders.remove(index);
}
void VoxelChunk::clear_colliders() {
void VoxelChunk::colliders_clear() {
_colliders.clear();
}
@ -1411,23 +1411,23 @@ void VoxelChunk::_bind_methods() {
ClassDB::bind_method(D_METHOD("mesh_data_resource_clear"), &VoxelChunk::mesh_data_resource_clear);
#endif
ClassDB::bind_method(D_METHOD("add_collider", "local_transform", "shape", "shape_rid", "body"), &VoxelChunk::add_collider, DEFVAL(RID()), DEFVAL(RID()));
ClassDB::bind_method(D_METHOD("collider_add", "local_transform", "shape", "shape_rid", "body"), &VoxelChunk::collider_add, DEFVAL(RID()), DEFVAL(RID()));
ClassDB::bind_method(D_METHOD("get_collider_transform", "index"), &VoxelChunk::get_collider_transform);
ClassDB::bind_method(D_METHOD("set_collider_transform", "index", "transform"), &VoxelChunk::set_collider_transform);
ClassDB::bind_method(D_METHOD("collider_get_transform", "index"), &VoxelChunk::collider_get_transform);
ClassDB::bind_method(D_METHOD("collider_set_transform", "index", "transform"), &VoxelChunk::collider_set_transform);
ClassDB::bind_method(D_METHOD("get_collider_shape", "index"), &VoxelChunk::get_collider_shape);
ClassDB::bind_method(D_METHOD("set_collider_shape", "index", "shape"), &VoxelChunk::set_collider_shape);
ClassDB::bind_method(D_METHOD("collider_get_shape", "index"), &VoxelChunk::collider_get_shape);
ClassDB::bind_method(D_METHOD("collider_set_shape", "index", "shape"), &VoxelChunk::collider_set_shape);
ClassDB::bind_method(D_METHOD("get_collider_shape_rid", "index"), &VoxelChunk::get_collider_shape_rid);
ClassDB::bind_method(D_METHOD("set_collider_shape_rid", "index", "rid"), &VoxelChunk::set_collider_shape_rid);
ClassDB::bind_method(D_METHOD("collider_get_shape_rid", "index"), &VoxelChunk::collider_get_shape_rid);
ClassDB::bind_method(D_METHOD("collider_set_shape_rid", "index", "rid"), &VoxelChunk::collider_set_shape_rid);
ClassDB::bind_method(D_METHOD("get_collider_body", "index"), &VoxelChunk::get_collider_body);
ClassDB::bind_method(D_METHOD("set_collider_body", "index", "rid"), &VoxelChunk::set_collider_body);
ClassDB::bind_method(D_METHOD("collider_get_body", "index"), &VoxelChunk::collider_get_body);
ClassDB::bind_method(D_METHOD("collider_set_body", "index", "rid"), &VoxelChunk::collider_set_body);
ClassDB::bind_method(D_METHOD("get_collider_count"), &VoxelChunk::get_collider_count);
ClassDB::bind_method(D_METHOD("remove_collider", "index"), &VoxelChunk::remove_collider);
ClassDB::bind_method(D_METHOD("clear_colliders"), &VoxelChunk::clear_colliders);
ClassDB::bind_method(D_METHOD("collider_get_count"), &VoxelChunk::collider_get_count);
ClassDB::bind_method(D_METHOD("collider_remove", "index"), &VoxelChunk::collider_remove);
ClassDB::bind_method(D_METHOD("colliders_clear"), &VoxelChunk::colliders_clear);
BIND_VMETHOD(MethodInfo("_build"));
ClassDB::bind_method(D_METHOD("build"), &VoxelChunk::build);

View File

@ -247,23 +247,23 @@ public:
#endif
//Colliders
int add_collider(const Transform &local_transform, const Ref<Shape> &shape, const RID &shape_rid = RID(), const RID &body = RID());
int collider_add(const Transform &local_transform, const Ref<Shape> &shape, const RID &shape_rid = RID(), const RID &body = RID());
Transform get_collider_transform(const int index);
void set_collider_transform(const int index, const Transform &transform);
Transform collider_get_transform(const int index);
void collider_set_transform(const int index, const Transform &transform);
Ref<Shape> get_collider_shape(const int index);
void set_collider_shape(const int index, const Ref<Shape> &shape);
Ref<Shape> collider_get_shape(const int index);
void collider_set_shape(const int index, const Ref<Shape> &shape);
RID get_collider_shape_rid(const int index);
void set_collider_shape_rid(const int index, const RID &rid);
RID collider_get_shape_rid(const int index);
void collider_set_shape_rid(const int index, const RID &rid);
RID get_collider_body(const int index);
void set_collider_body(const int index, const RID &rid);
RID collider_get_body(const int index);
void collider_set_body(const int index, const RID &rid);
int get_collider_count() const;
void remove_collider(const int index);
void clear_colliders();
int collider_get_count() const;
void collider_remove(const int index);
void colliders_clear();
//handlers
void enter_tree();