fix(physics): use max(CylSphere.Radius, Setup.Radius) for collision
The CylSphere.Radius from the dat is often smaller than the visual trunk base. Setup.Radius is the overall bounding radius which better matches the visual footprint. Use the larger of the two to prevent clipping into wide tree bases. Also use Setup.Height as fallback when CylSphere.Height is zero. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bfe6a49d67
commit
76cf7a85ec
1 changed files with 8 additions and 3 deletions
|
|
@ -1810,16 +1810,21 @@ public sealed class GameWindow : IDisposable
|
|||
if (setup is not null && setup.CylSpheres.Count > 0)
|
||||
{
|
||||
var cyl = setup.CylSpheres[0];
|
||||
float cylRadius = cyl.Radius > 0 ? cyl.Radius : setup.Radius;
|
||||
// Use the LARGER of CylSphere.Radius and Setup.Radius.
|
||||
// Setup.Radius is the overall bounding radius of the object.
|
||||
float cylRadius = MathF.Max(cyl.Radius, setup.Radius);
|
||||
if (cylRadius <= 0) cylRadius = 1f;
|
||||
float cylHeight = cyl.Height > 0 ? cyl.Height : setup.Height;
|
||||
if (cylHeight <= 0) cylHeight = cylRadius * 4f;
|
||||
|
||||
if (cylRadius > 0)
|
||||
{
|
||||
// Use entity.Id directly (not partId) for the CylSphere entry.
|
||||
_physicsEngine.ShadowObjects.Register(
|
||||
entity.Id, entity.SourceGfxObjOrSetupId,
|
||||
entity.Position + new System.Numerics.Vector3(cyl.Origin.X, cyl.Origin.Y, cyl.Origin.Z),
|
||||
entity.Rotation, cylRadius,
|
||||
origin.X, origin.Y, lb.LandblockId,
|
||||
AcDream.Core.Physics.ShadowCollisionType.Cylinder, cyl.Height);
|
||||
AcDream.Core.Physics.ShadowCollisionType.Cylinder, cylHeight);
|
||||
}
|
||||
}
|
||||
else if (setup is not null && setup.Spheres.Count > 0 && partIndex == 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue