Fixed LODs culling issue

This commit is contained in:
dexy 2019-12-11 22:38:59 +11:00
parent 968a611aa9
commit 2b02ad0091
2 changed files with 5 additions and 6 deletions

View File

@ -1475,11 +1475,10 @@ namespace CodeWalker.GameFiles
BSRadius = Archetype.BSRadius * Math.Max(Scale.X, Scale.Z);
if (Orientation == Quaternion.Identity)
{
BBMin = (Archetype.BBMin * Scale) + Position;
BBMax = (Archetype.BBMax * Scale) + Position;
BBMin = (Vector3.Min(Archetype.BBMin, Archetype.BBMax) * Scale) + Position;
BBMax = (Vector3.Max(Archetype.BBMin, Archetype.BBMax) * Scale) + Position;
BBCenter = (BBMax + BBMin) * 0.5f;
BBExtent = (BBMax - BBMin) * 0.5f;
BBExtent = BBExtent.Abs();
}
else
{
@ -1492,7 +1491,7 @@ namespace CodeWalker.GameFiles
var bbcenter = (Archetype.BBMax + Archetype.BBMin) * 0.5f;
var bbextent = (Archetype.BBMax - Archetype.BBMin) * 0.5f;
var ncenter = Vector3.TransformCoordinate(bbcenter, mat);
var nextent = Vector3.TransformNormal(bbextent, matabs);
var nextent = Vector3.TransformNormal(bbextent, matabs).Abs();
BBCenter = ncenter;
BBExtent = nextent;
BBMin = ncenter - nextent;

View File

@ -3651,7 +3651,7 @@ namespace CodeWalker.Rendering
foreach (var kvp in RootEntities)
{
var ent = kvp.Key;
if (EntityVisibleAtMaxLodLevel(ent) && EntityVisible(ent))
if (EntityVisibleAtMaxLodLevel(ent))
{
ent.Distance = MapViewEnabled ? MapViewDist : (ent.Position - Position).Length();
if (ent.Distance <= (ent.LodDist * LodDistMult))
@ -3676,7 +3676,7 @@ namespace CodeWalker.Rendering
}
else
{
if ((ent.Parent == null) || EntityVisible(ent))
if (EntityVisible(ent))
{
VisibleLeaves.Add(ent);
}