mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-22 15:02:54 +08:00
Ymap frustum culling
This commit is contained in:
parent
a434d9ad55
commit
bd283a5c07
@ -334,5 +334,20 @@ namespace CodeWalker.World
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool ContainsAABBNoClipNoOpt(ref Vector3 bmin, ref Vector3 bmax)
|
||||
{
|
||||
var c = (bmax + bmin) * 0.5f - Position;
|
||||
var e = (bmax - bmin) * 0.5f;
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
var pd = Planes[i].D;
|
||||
var pn = Planes[i].Normal;
|
||||
var d = (c.X * pn.X) + (c.Y * pn.Y) + (c.Z * pn.Z);
|
||||
var r = (e.X * (pn.X > 0 ? pn.X : -pn.X)) + (e.Y * (pn.Y > 0 ? pn.Y : -pn.Y)) + (e.Z * (pn.Z > 0 ? pn.Z : -pn.Z));
|
||||
if ((d + r) < -pd) return false;
|
||||
//if ((d - r) < -pd) ; //intersecting
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1672,6 +1672,16 @@ namespace CodeWalker.Rendering
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ymap.HasChanged)//don't cull edited project ymaps, because extents may not have been updated!
|
||||
{
|
||||
var eemin = ymap._CMapData.entitiesExtentsMin;
|
||||
var eemax = ymap._CMapData.entitiesExtentsMax;
|
||||
if (!camera.ViewFrustum.ContainsAABBNoClipNoOpt(ref eemin, ref eemax))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
private void RenderWorldCalcEntityVisibility(YmapEntityDef ent)
|
||||
@ -2522,6 +2532,19 @@ namespace CodeWalker.Rendering
|
||||
{
|
||||
RenderCollisionMesh(sdrawable.Bound, entity);
|
||||
}
|
||||
//FragDrawable fdrawable = rndbl.Key as FragDrawable;
|
||||
//if (fdrawable != null)
|
||||
//{
|
||||
// if (fdrawable.Bound != null)
|
||||
// {
|
||||
// RenderCollisionMesh(fdrawable.Bound, entity);
|
||||
// }
|
||||
// var fbound = fdrawable.OwnerFragment?.PhysicsLODGroup?.PhysicsLOD1?.Bound;
|
||||
// if (fbound != null)
|
||||
// {
|
||||
// RenderCollisionMesh(fbound, entity);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
if (renderskeletons && rndbl.HasSkeleton)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user