Fixed collisions bound geometry render transform bug

This commit is contained in:
dexy 2020-03-22 10:09:46 +11:00
parent f98a7c8411
commit 32e75cb2a1

View File

@ -3243,15 +3243,27 @@ namespace CodeWalker.Rendering
{ {
RenderableBoundGeometryInst rbginst = new RenderableBoundGeometryInst(); RenderableBoundGeometryInst rbginst = new RenderableBoundGeometryInst();
rbginst.Inst.Renderable = rndbc; rbginst.Inst.Renderable = rndbc;
rbginst.Inst.Orientation = orientation;
rbginst.Inst.Scale = scale;
if (rndbc.Geometries != null) if (rndbc.Geometries != null)
{ {
foreach (var geom in rndbc.Geometries) foreach (var geom in rndbc.Geometries)
{ {
if (geom == null) continue; if (geom == null) continue;
rbginst.Geom = geom; 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; rbginst.Inst.CamRel = rbginst.Inst.Position - camera.Position;
shaders.Enqueue(ref rbginst); shaders.Enqueue(ref rbginst);
} }