feat(physics): CylSphere collision for trees, rocks, NPCs
Most scenery objects (trees, rocks) use CylSphere collision from their Setup, not PhysicsBSP. Register these in ShadowObjectRegistry with a Cylinder collision type. FindObjCollisions now handles both: - BSP: full polygon collision via BSPQuery (buildings, stabs) - Cylinder: radial + vertical cylinder-sphere test (trees, NPCs) Diagnostics showed 170 CylSphere entities vs 278 BSP entities in the Holtburg landblock alone — this roughly doubles collision coverage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2a4aaf4db7
commit
14b0a6e2b8
3 changed files with 119 additions and 23 deletions
|
|
@ -21,9 +21,10 @@ public sealed class ShadowObjectRegistry
|
|||
/// Register an entity into the cells it overlaps based on world position + radius.
|
||||
/// </summary>
|
||||
public void Register(uint entityId, uint gfxObjId, Vector3 worldPos, Quaternion rotation,
|
||||
float radius, float worldOffsetX, float worldOffsetY, uint landblockId)
|
||||
float radius, float worldOffsetX, float worldOffsetY, uint landblockId,
|
||||
ShadowCollisionType collisionType = ShadowCollisionType.BSP,
|
||||
float cylHeight = 0f)
|
||||
{
|
||||
// Deregister first if already registered (handles position updates)
|
||||
Deregister(entityId);
|
||||
|
||||
float localX = worldPos.X - worldOffsetX;
|
||||
|
|
@ -34,7 +35,7 @@ public sealed class ShadowObjectRegistry
|
|||
int minCy = Math.Max(0, (int)((localY - radius) / 24f));
|
||||
int maxCy = Math.Min(7, (int)((localY + radius) / 24f));
|
||||
|
||||
var entry = new ShadowEntry(entityId, gfxObjId, worldPos, rotation, radius);
|
||||
var entry = new ShadowEntry(entityId, gfxObjId, worldPos, rotation, radius, collisionType, cylHeight);
|
||||
var cellIds = new List<uint>();
|
||||
|
||||
uint lbPrefix = landblockId & 0xFFFF0000u;
|
||||
|
|
@ -146,9 +147,17 @@ public sealed class ShadowObjectRegistry
|
|||
public int TotalRegistered => _entityToCells.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Collision type for a shadow entry. BSP uses full polygon collision.
|
||||
/// Cylinder uses a simple cylinder-sphere intersection test.
|
||||
/// </summary>
|
||||
public enum ShadowCollisionType : byte { BSP, Cylinder }
|
||||
|
||||
public readonly record struct ShadowEntry(
|
||||
uint EntityId,
|
||||
uint GfxObjId,
|
||||
Vector3 Position,
|
||||
Quaternion Rotation,
|
||||
float Radius);
|
||||
float Radius,
|
||||
ShadowCollisionType CollisionType = ShadowCollisionType.BSP,
|
||||
float CylHeight = 0f);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue