Re-orient capsule to colission shape
This commit is contained in:
parent
afbb5261e6
commit
f02ccffca3
1 changed files with 19 additions and 17 deletions
|
@ -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++;
|
||||
|
||||
|
|
Loading…
Reference in a new issue