From 32e75cb2a13331676bd9d9fafcf736cd44ed049d Mon Sep 17 00:00:00 2001 From: dexy Date: Sun, 22 Mar 2020 10:09:46 +1100 Subject: [PATCH] Fixed collisions bound geometry render transform bug --- CodeWalker/Rendering/Renderer.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/CodeWalker/Rendering/Renderer.cs b/CodeWalker/Rendering/Renderer.cs index f2c2e69..23e6347 100644 --- a/CodeWalker/Rendering/Renderer.cs +++ b/CodeWalker/Rendering/Renderer.cs @@ -3243,15 +3243,27 @@ namespace CodeWalker.Rendering { RenderableBoundGeometryInst rbginst = new RenderableBoundGeometryInst(); rbginst.Inst.Renderable = rndbc; - rbginst.Inst.Orientation = orientation; - rbginst.Inst.Scale = scale; if (rndbc.Geometries != null) { foreach (var geom in rndbc.Geometries) { if (geom == null) continue; rbginst.Geom = geom; - rbginst.Inst.Position = position + orientation.Multiply(geom.CenterGeom * scale); + + var pos = position; + var ori = orientation; + var sca = scale; + if (geom.Bound is BoundGeometry bgeom) + { + var rmat = bgeom.Transform; + sca = scale * rmat.ScaleVector; + pos = position + orientation.Multiply(rmat.TranslationVector); + rmat.TranslationVector = Vector3.Zero; + ori = orientation * Quaternion.RotationMatrix(rmat); + } + rbginst.Inst.Position = pos + ori.Multiply(geom.CenterGeom * sca); + rbginst.Inst.Orientation = ori; + rbginst.Inst.Scale = sca; rbginst.Inst.CamRel = rbginst.Inst.Position - camera.Position; shaders.Enqueue(ref rbginst); }