Fix box, cylinder, capsule offsets.

This commit is contained in:
Relintai 2020-06-30 15:08:25 +02:00
parent 5f8ab950b1
commit 25e9135925
2 changed files with 24 additions and 6 deletions

View File

@ -152,7 +152,10 @@ Error EditorImportColladaMdr::import(const String &p_source_file, const String &
shape->set_extents(size * 0.5);
mdr->add_collision_shape(aabb.position, shape);
Vector3 pos = aabb.position;
pos += size / 2.0;
mdr->add_collision_shape(pos, shape);
} else if (collider_type == MeshDataResource::COLLIDER_TYPE_APPROXIMATED_CAPSULE) {
Ref<ArrayMesh> m;
m.instance();
@ -167,7 +170,10 @@ Error EditorImportColladaMdr::import(const String &p_source_file, const String &
shape->set_height(size.y * 0.5);
shape->set_radius(MIN(size.x, size.z) * 0.5);
mdr->add_collision_shape(aabb.position, shape);
Vector3 pos = aabb.position;
pos += size / 2.0;
mdr->add_collision_shape(pos, shape);
} else if (collider_type == MeshDataResource::COLLIDER_TYPE_APPROXIMATED_CYLINDER) {
Ref<ArrayMesh> m;
m.instance();
@ -182,7 +188,10 @@ Error EditorImportColladaMdr::import(const String &p_source_file, const String &
shape->set_height(size.y * 0.5);
shape->set_radius(MIN(size.x, size.z) * 0.5);
mdr->add_collision_shape(aabb.position, shape);
Vector3 pos = aabb.position;
pos += size / 2.0;
mdr->add_collision_shape(pos, shape);
} else if (collider_type == MeshDataResource::COLLIDER_TYPE_APPROXIMATED_SPHERE) {
Ref<ArrayMesh> m;
m.instance();

View File

@ -154,7 +154,10 @@ Error EditorImportGLTFMdr::import(const String &p_source_file, const String &p_s
shape->set_extents(size * 0.5);
mdr->add_collision_shape(aabb.position, shape);
Vector3 pos = aabb.position;
pos += size / 2.0;
mdr->add_collision_shape(pos, shape);
} else if (collider_type == MeshDataResource::COLLIDER_TYPE_APPROXIMATED_CAPSULE) {
Ref<ArrayMesh> m;
m.instance();
@ -169,7 +172,10 @@ Error EditorImportGLTFMdr::import(const String &p_source_file, const String &p_s
shape->set_height(size.y * 0.5);
shape->set_radius(MIN(size.x, size.z) * 0.5);
mdr->add_collision_shape(aabb.position, shape);
Vector3 pos = aabb.position;
pos += size / 2.0;
mdr->add_collision_shape(pos, shape);
} else if (collider_type == MeshDataResource::COLLIDER_TYPE_APPROXIMATED_CYLINDER) {
Ref<ArrayMesh> m;
m.instance();
@ -184,7 +190,10 @@ Error EditorImportGLTFMdr::import(const String &p_source_file, const String &p_s
shape->set_height(size.y * 0.5);
shape->set_radius(MIN(size.x, size.z) * 0.5);
mdr->add_collision_shape(aabb.position, shape);
Vector3 pos = aabb.position;
pos += size / 2.0;
mdr->add_collision_shape(pos, shape);
} else if (collider_type == MeshDataResource::COLLIDER_TYPE_APPROXIMATED_SPHERE) {
Ref<ArrayMesh> m;
m.instance();