Collision detection refactoring and improvements

This commit is contained in:
dexy
2019-12-10 18:33:45 +11:00
Unverified
parent 58d2293358
commit d5c0bc2477
7 changed files with 1022 additions and 375 deletions
+1 -2
View File
@@ -1899,13 +1899,12 @@ namespace CodeWalker.Rendering
}
RenderableBoundGeometry[] geoms = new RenderableBoundGeometry[bound.Children.data_items.Length];
var childTransforms = bound.ChildrenTransformation1 ?? bound.ChildrenTransformation2;
long dsize = 0;
for (int i = 0; i < bound.Children.data_items.Length; i++)
{
var rgeom = new RenderableBoundGeometry(this);
var child = bound.Children.data_items[i];
var xform = ((childTransforms != null) && (i < childTransforms.Length)) ? childTransforms[i] : Matrix.Identity; xform.Column4 = new Vector4(0.0f, 0.0f, 0.0f, 1.0f);
var xform = (child != null) ? child.Transform : Matrix.Identity;
if (child is BoundGeometry bgeom)
{
rgeom.Init(bgeom);
+15 -12
View File
@@ -2804,22 +2804,25 @@ namespace CodeWalker.Rendering
if ((rendercollisionmeshes || (SelectionMode == MapSelectionMode.Collision)) && rendercollisionmeshlayerdrawable)
{
Drawable sdrawable = rndbl.Key as Drawable;
if ((sdrawable != null) && (sdrawable.Bound != null))
if ((entity == null) || ((entity._CEntityDef.flags & 4) == 0)) //skip if entity embedded collisions disabled
{
RenderCollisionMesh(sdrawable.Bound, entity);
}
FragDrawable fdrawable = rndbl.Key as FragDrawable;
if (fdrawable != null)
{
if (fdrawable.Bound != null)
Drawable sdrawable = rndbl.Key as Drawable;
if ((sdrawable != null) && (sdrawable.Bound != null))
{
RenderCollisionMesh(fdrawable.Bound, entity);
RenderCollisionMesh(sdrawable.Bound, entity);
}
var fbound = fdrawable.OwnerFragment?.PhysicsLODGroup?.PhysicsLOD1?.Bound;
if (fbound != null)
FragDrawable fdrawable = rndbl.Key as FragDrawable;
if (fdrawable != null)
{
RenderCollisionMesh(fbound, entity);//TODO: these probably have extra transforms..!
if (fdrawable.Bound != null)
{
RenderCollisionMesh(fdrawable.Bound, entity);
}
var fbound = fdrawable.OwnerFragment?.PhysicsLODGroup?.PhysicsLOD1?.Bound;
if (fbound != null)
{
RenderCollisionMesh(fbound, entity);//TODO: these probably have extra transforms..!
}
}
}
}