Table of Contents

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

CachedCuboidListFaster

entityBox

public Cuboidd entityBox

Field Value

Cuboidd

maxPos

public BlockPos maxPos

Field Value

BlockPos

minPos

public BlockPos minPos

Field Value

BlockPos

pos

public Vec3d pos

Field Value

Vec3d

tmpPos

public BlockPos tmpPos

Field Value

BlockPos

tmpPosDelta

public Vec3d tmpPosDelta

Field Value

Vec3d

Properties

SlidingOnSteepCollider

Whether the latest collision contacted a steep collider without being walkable

public bool SlidingOnSteepCollider { get; }

Property Value

bool

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

Collider

Methods

AabbIntersect(Cuboidd, Cuboidd, Vec3d)

public static EnumIntersect AabbIntersect(Cuboidd aabb, Cuboidd aabb2, Vec3d motion)

Parameters

aabb Cuboidd
aabb2 Cuboidd
motion Vec3d

Returns

EnumIntersect

AabbIntersect(Cuboidf, double, double, double, Cuboidf, Vec3d)

public static bool AabbIntersect(Cuboidf aabb, double x, double y, double z, Cuboidf aabb2, Vec3d pos)

Parameters

aabb Cuboidf
x double
y double
z double
aabb2 Cuboidf
pos Vec3d

Returns

bool

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

entity Entity
entityPos EntityPos
dtFactor float
newPosition Vec3d
stepHeight float
yExtra float

Default 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

entity Entity
entityPos EntityPos
displacement Vec3d
dtFactor float
newPosition Vec3d
excludedColliderId long

A collider which supplies the displacement and must not block it.

stepHeight float
yExtra float

ClipColliderVelocity(Vec3d)

Clips horizontal velocity against registered collider walls which constrained the latest movement solve.

public bool ClipColliderVelocity(Vec3d velocity)

Parameters

velocity Vec3d

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

blockAccessor IBlockAccessor
motionX double
motionY double
motionZ double
stepHeight float
yExtra float
dimension int

GetCollidingBlock(IBlockAccessor, Cuboidf, Vec3d, bool)

public Block GetCollidingBlock(IBlockAccessor blockAccessor, Cuboidf entityBoxRel, Vec3d pos, bool alsoCheckTouch = true)

Parameters

blockAccessor IBlockAccessor
entityBoxRel Cuboidf
pos Vec3d
alsoCheckTouch bool

Returns

Block

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

blockAccessor IBlockAccessor
entityBoxRel Cuboidf
pos Vec3d
dimension int
alsoCheckTouch bool

Returns

Block

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

blockAccessor IBlockAccessor
entityBoxRel Cuboidf
pos Vec3d
alsoCheckTouch bool

Returns

Cuboidd

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

blockAccessor IBlockAccessor
entityBoxRel Cuboidf
pos Vec3d
intoCuboid Cuboidd
alsoCheckTouch bool
dimension int

Returns

bool

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

blockAccessor IBlockAccessor
entityBoxRel Cuboidf
pos Vec3d
alsoCheckTouch bool

Returns

bool

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

blockAccessor IBlockAccessor
entityBoxRel Cuboidf
pos Vec3d
dimension int
alsoCheckTouch bool

Returns

bool

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

worldAccessor IWorldAccessor
entityBoxRel Cuboidf
pos Vec3d
dimension int
alsoCheckTouch bool

Returns

bool

IsWalkableColliderSurface(FastVec3d, double)

public static bool IsWalkableColliderSurface(FastVec3d normal, double maxSlopeGrade)

Parameters

normal FastVec3d
maxSlopeGrade double

Returns

bool