summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclayjohn <claynjohn@gmail.com>2024-02-23 10:22:01 -0800
committerclayjohn <claynjohn@gmail.com>2024-02-23 21:19:21 -0800
commitf267b2aa87597a78fed9f0d086b18e47dd761a01 (patch)
tree617ee3c2c46d96dee4f0cee47c63238087c90c52
parent16d61427cab3a8e43f0a9a8ee724fc176b6433c6 (diff)
downloadredot-engine-f267b2aa87597a78fed9f0d086b18e47dd761a01.tar.gz
Properly calculate binormal when creating SurfaceTool from arrays
-rw-r--r--scene/resources/surface_tool.cpp6
-rw-r--r--servers/rendering_server.cpp2
2 files changed, 4 insertions, 4 deletions
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index 653f234d3d..f51d8dd0bf 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -880,9 +880,9 @@ void SurfaceTool::create_vertex_array_from_triangle_arrays(const Array &p_arrays
v.normal = narr[i];
}
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 = p.normal;
- v.binormal = p.normal.cross(v.tangent).normalized() * p.d;
+ v.tangent = Vector3(tarr[i * 4 + 0], tarr[i * 4 + 1], tarr[i * 4 + 2]);
+ float d = tarr[i * 4 + 3];
+ v.binormal = v.normal.cross(v.tangent).normalized() * d;
}
if (lformat & RS::ARRAY_FORMAT_COLOR) {
v.color = carr[i];
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index 6e9b525f31..d1c3aaf6f7 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -340,7 +340,7 @@ void _get_axis_angle(const Vector3 &p_normal, const Vector4 &p_tangent, float &r
if (d < 0.0) {
r_angle = CLAMP((1.0 - r_angle / Math_PI) * 0.5, 0.0, 0.49999);
} 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);
}
}