Class CollisionTester
- Namespace
- Vintagestory.API.MathTools
- Assembly
- VintagestoryAPI.dll
public class CollisionTester
- Inheritance
-
CollisionTester
- Derived
- Inherited Members
- Extension Methods
Fields
CollisionBoxList
public CachedCuboidListFaster CollisionBoxList
Field Value
entityBox
public Cuboidd entityBox
Field Value
maxPos
public BlockPos maxPos
Field Value
minPos
public BlockPos minPos
Field Value
pos
public Vec3d pos
Field Value
tmpPos
public BlockPos tmpPos
Field Value
tmpPosDelta
public Vec3d tmpPosDelta
Field Value
Properties
SlidingOnSteepCollider
Whether the latest collision contacted a steep collider without being walkable
public bool SlidingOnSteepCollider { get; }
Property Value
SupportingCollider
The registered collider which supported the entity during the most recent terrain collision, or null for terrain and non-floor collisions.
public Collider SupportingCollider { get; }
Property Value
Methods
AabbIntersect(Cuboidd, Cuboidd, Vec3d)
public static EnumIntersect AabbIntersect(Cuboidd aabb, Cuboidd aabb2, Vec3d motion)
Parameters
Returns
AabbIntersect(Cuboidf, double, double, double, Cuboidf, Vec3d)
public static bool AabbIntersect(Cuboidf aabb, double x, double y, double z, Cuboidf aabb2, Vec3d pos)
Parameters
Returns
ApplyTerrainCollision(Entity, EntityPos, float, ref Vec3d, float, float)
Takes the entity positiona and motion and adds them, respecting any colliding blocks. The resulting new position is put into outposition
public void ApplyTerrainCollision(Entity entity, EntityPos entityPos, float dtFactor, ref Vec3d newPosition, float stepHeight = 1, float yExtra = 1)
Parameters
entityEntityentityPosEntityPosdtFactorfloatnewPositionVec3dstepHeightfloatyExtrafloatDefault 1 for the extra high collision boxes of fences
ApplyTerrainCollision(Entity, EntityPos, Vec3d, float, ref Vec3d, long, float, float)
Applies an explicit displacement while respecting terrain and registered colliders.
public void ApplyTerrainCollision(Entity entity, EntityPos entityPos, Vec3d displacement, float dtFactor, ref Vec3d newPosition, long excludedColliderId = 0, float stepHeight = 1, float yExtra = 1)
Parameters
entityEntityentityPosEntityPosdisplacementVec3ddtFactorfloatnewPositionVec3dexcludedColliderIdlongA collider which supplies the displacement and must not block it.
stepHeightfloatyExtrafloat
ClipColliderVelocity(Vec3d)
Clips horizontal velocity against registered collider walls which constrained the latest movement solve.
public bool ClipColliderVelocity(Vec3d velocity)
Parameters
velocityVec3d
Returns
- bool
True when the latest solve applied at least one wall constraint.
GenerateCollisionBoxList(IBlockAccessor, double, double, double, float, float, int)
protected virtual void GenerateCollisionBoxList(IBlockAccessor blockAccessor, double motionX, double motionY, double motionZ, float stepHeight, float yExtra, int dimension)
Parameters
blockAccessorIBlockAccessormotionXdoublemotionYdoublemotionZdoublestepHeightfloatyExtrafloatdimensionint
GetCollidingBlock(IBlockAccessor, Cuboidf, Vec3d, bool)
public Block GetCollidingBlock(IBlockAccessor blockAccessor, Cuboidf entityBoxRel, Vec3d pos, bool alsoCheckTouch = true)
Parameters
blockAccessorIBlockAccessorentityBoxRelCuboidfposVec3dalsoCheckTouchbool
Returns
GetCollidingBlock(IBlockAccessor, Cuboidf, Vec3d, int, bool)
Gets the colliding terrain block at a dimension-local position in the supplied dimension.
public Block GetCollidingBlock(IBlockAccessor blockAccessor, Cuboidf entityBoxRel, Vec3d pos, int dimension, bool alsoCheckTouch = true)
Parameters
blockAccessorIBlockAccessorentityBoxRelCuboidfposVec3ddimensionintalsoCheckTouchbool
Returns
GetCollidingCollisionBox(IBlockAccessor, Cuboidf, Vec3d, bool)
If given cuboidf collides with the terrain, returns the collision box it collides with. By default also checks if the cuboid is merely touching the terrain, set alsoCheckTouch to disable that.
public Cuboidd GetCollidingCollisionBox(IBlockAccessor blockAccessor, Cuboidf entityBoxRel, Vec3d pos, bool alsoCheckTouch = true)
Parameters
blockAccessorIBlockAccessorentityBoxRelCuboidfposVec3dalsoCheckTouchbool
Returns
GetCollidingCollisionBox(IBlockAccessor, Cuboidf, Vec3d, ref Cuboidd, bool, int)
Tests given cuboidf collides with the terrain. By default also checks if the cuboid is merely touching the terrain, set alsoCheckTouch to disable that.
NOTE: currently not dimension-aware unless the supplied Vec3d pos is dimension-aware
public bool GetCollidingCollisionBox(IBlockAccessor blockAccessor, Cuboidf entityBoxRel, Vec3d pos, ref Cuboidd intoCuboid, bool alsoCheckTouch = true, int dimension = 0)
Parameters
blockAccessorIBlockAccessorentityBoxRelCuboidfposVec3dintoCuboidCuboiddalsoCheckTouchbooldimensionint
Returns
IsColliding(IBlockAccessor, Cuboidf, Vec3d, bool)
Tests given cuboidf collides with the terrain. By default also checks if the cuboid is merely touching the terrain, set alsoCheckTouch to disable that.
public bool IsColliding(IBlockAccessor blockAccessor, Cuboidf entityBoxRel, Vec3d pos, bool alsoCheckTouch = true)
Parameters
blockAccessorIBlockAccessorentityBoxRelCuboidfposVec3dalsoCheckTouchbool
Returns
IsColliding(IBlockAccessor, Cuboidf, Vec3d, int, bool)
Tests terrain collision at a dimension-local position in the supplied dimension.
public bool IsColliding(IBlockAccessor blockAccessor, Cuboidf entityBoxRel, Vec3d pos, int dimension, bool alsoCheckTouch = true)
Parameters
blockAccessorIBlockAccessorentityBoxRelCuboidfposVec3ddimensionintalsoCheckTouchbool
Returns
IsColliding(IWorldAccessor, Cuboidf, Vec3d, int, bool)
Tests terrain and registered colliders at a dimension-local position in the supplied dimension.
public bool IsColliding(IWorldAccessor worldAccessor, Cuboidf entityBoxRel, Vec3d pos, int dimension, bool alsoCheckTouch = true)
Parameters
worldAccessorIWorldAccessorentityBoxRelCuboidfposVec3ddimensionintalsoCheckTouchbool
Returns
IsWalkableColliderSurface(FastVec3d, double)
public static bool IsWalkableColliderSurface(FastVec3d normal, double maxSlopeGrade)