You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Properly calculate binormal when creating SurfaceTool from arrays
(cherry picked from commit f267b2aa87)
This commit is contained in:
committed by
Rémi Verschelde
parent
4142e57082
commit
a61a84ff09
@@ -880,9 +880,9 @@ void SurfaceTool::create_vertex_array_from_triangle_arrays(const Array &p_arrays
|
|||||||
v.normal = narr[i];
|
v.normal = narr[i];
|
||||||
}
|
}
|
||||||
if (lformat & RS::ARRAY_FORMAT_TANGENT) {
|
if (lformat & RS::ARRAY_FORMAT_TANGENT) {
|
||||||
Plane p(tarr[i * 4 + 0], tarr[i * 4 + 1], tarr[i * 4 + 2], tarr[i * 4 + 3]);
|
v.tangent = Vector3(tarr[i * 4 + 0], tarr[i * 4 + 1], tarr[i * 4 + 2]);
|
||||||
v.tangent = p.normal;
|
float d = tarr[i * 4 + 3];
|
||||||
v.binormal = p.normal.cross(v.tangent).normalized() * p.d;
|
v.binormal = v.normal.cross(v.tangent).normalized() * d;
|
||||||
}
|
}
|
||||||
if (lformat & RS::ARRAY_FORMAT_COLOR) {
|
if (lformat & RS::ARRAY_FORMAT_COLOR) {
|
||||||
v.color = carr[i];
|
v.color = carr[i];
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ void _get_axis_angle(const Vector3 &p_normal, const Vector4 &p_tangent, float &r
|
|||||||
if (d < 0.0) {
|
if (d < 0.0) {
|
||||||
r_angle = CLAMP((1.0 - r_angle / Math_PI) * 0.5, 0.0, 0.49999);
|
r_angle = CLAMP((1.0 - r_angle / Math_PI) * 0.5, 0.0, 0.49999);
|
||||||
} else {
|
} else {
|
||||||
r_angle = (r_angle / Math_PI) * 0.5 + 0.5;
|
r_angle = CLAMP((r_angle / Math_PI) * 0.5 + 0.5, 0.500008, 1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user