diff options
author | BastiaanOlij <mux213@gmail.com> | 2017-07-03 23:53:06 +1000 |
---|---|---|
committer | BastiaanOlij <mux213@gmail.com> | 2017-07-03 23:53:06 +1000 |
commit | f02ccffca3fb890871666470fbcfcc81a889a5b0 (patch) | |
tree | a0f3c8668dfdec2870e0cacf245cea2124dce422 /scene/resources | |
parent | afbb5261e660acf08dd62f698d353e95fc7fb6bb (diff) |
Re-orient capsule to colission shape
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/primitive_meshes.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 6e41cef4a0..81cfd0e5f0 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -171,7 +171,9 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) { float onethird = 1.0 / 3.0; float twothirds = 2.0 / 3.0; - set_aabb(Rect3(Vector3(-radius, (mid_height * -0.5) - radius, -radius), Vector3(radius * 2.0, mid_height + (2.0 * radius), radius * 2.0))); + // note, this has been aligned with our collision shape but I've left the descriptions as top/middle/bottom + + set_aabb(Rect3(Vector3(-radius, -radius, (mid_height * -0.5) - radius), Vector3(radius * 2.0, radius * 2.0, mid_height + (2.0 * radius)))); PoolVector<Vector3> points; PoolVector<Vector3> normals; @@ -195,19 +197,19 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) { v /= (rings + 1); w = sin(0.5 * Math_PI * v); - y = radius * cos(0.5 * Math_PI * v); + z = radius * cos(0.5 * Math_PI * v); for (i = 0; i <= radial_segments; i++) { u = i; u /= radial_segments; x = sin(u * (Math_PI * 2.0)); - z = cos(u * (Math_PI * 2.0)); + y = -cos(u * (Math_PI * 2.0)); - Vector3 p = Vector3(x * radius * w, y, z * radius * w); - points.push_back(p + Vector3(0.0, 0.5 * mid_height, 0.0)); + Vector3 p = Vector3(x * radius * w, y * radius * w, z); + points.push_back(p + Vector3(0.0, 0.0, 0.5 * mid_height)); normals.push_back(p.normalized()); - ADD_TANGENT(-z, 0.0, x, -1.0) + ADD_TANGENT(y, -x, 0.0, -1.0) uvs.push_back(Vector2(u, v * onethird)); point++; @@ -233,20 +235,20 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) { v = j; v /= (rings + 1); - y = mid_height * v; - y = (mid_height * 0.5) - y; + z = mid_height * v; + z = (mid_height * 0.5) - z; for (i = 0; i <= radial_segments; i++) { u = i; u /= radial_segments; x = sin(u * (Math_PI * 2.0)); - z = cos(u * (Math_PI * 2.0)); + y = -cos(u * (Math_PI * 2.0)); - Vector3 p = Vector3(x * radius, y, z * radius); + Vector3 p = Vector3(x * radius, y * radius, z); points.push_back(p); - normals.push_back(Vector3(x, 0.0, z)); - ADD_TANGENT(-z, 0.0, x, -1.0) + normals.push_back(Vector3(x, y, 0.0)); + ADD_TANGENT(y, -x, 0.0, -1.0) uvs.push_back(Vector2(u, onethird + (v * onethird))); point++; @@ -275,19 +277,19 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) { v /= (rings + 1); v += 1.0; w = sin(0.5 * Math_PI * v); - y = radius * cos(0.5 * Math_PI * v); + z = radius * cos(0.5 * Math_PI * v); for (i = 0; i <= radial_segments; i++) { float u = i; u /= radial_segments; x = sin(u * (Math_PI * 2.0)); - z = cos(u * (Math_PI * 2.0)); + y = -cos(u * (Math_PI * 2.0)); - Vector3 p = Vector3(x * radius * w, y, z * radius * w); - points.push_back(p + Vector3(0.0, -0.5 * mid_height, 0.0)); + Vector3 p = Vector3(x * radius * w, y * radius * w, z); + points.push_back(p + Vector3(0.0, 0.0, -0.5 * mid_height)); normals.push_back(p.normalized()); - ADD_TANGENT(-z, 0.0, x, -1.0) + ADD_TANGENT(y, -x, 0.0, -1.0) uvs.push_back(Vector2(u, twothirds + ((v - 1.0) * onethird))); point++; |