Interface ICollisionScene
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
Stores and queries persistent colliders outside the normal terrain and entity broad phases. Registration changes and queries may run concurrently. Returned snapshots remain valid after their registration is updated or removed.
public interface ICollisionScene : IDisposable
- Inherited Members
- Extension Methods
Methods
GetColliders(Cuboidd, int, List<Collider>, CollisionQueryFilter?)
Replaces results with the colliders whose bounds overlap the supplied axis-aligned, dimension-local bounds.
Returned colliders and their boxes are owned by the scene and must not be modified.
The caller owns the results list and must not use the same list from concurrent queries.
void GetColliders(Cuboidd bounds, int dimension, List<Collider> results, CollisionQueryFilter? filter = null)
Parameters
boundsCuboidddimensionintresultsList<Collider>filterCollisionQueryFilter?
GetIntersectingColliders(TransformedCuboidd, int, List<Collider>, bool, CollisionQueryFilter?)
Replaces results with colliders whose exact boxes intersect the supplied transformed cuboid.
The query box must not be mutated until this call returns.
void GetIntersectingColliders(TransformedCuboidd box, int dimension, List<Collider> results, bool alsoCheckTouch = true, CollisionQueryFilter? filter = null)
Parameters
boxTransformedCuboidddimensionintresultsList<Collider>alsoCheckTouchboolfilterCollisionQueryFilter?
IntersectsAny(Cuboidd, int, bool, CollisionQueryFilter?)
Tests the exact boxes of the registered colliders against the supplied axis-aligned, dimension-local bounds. Unlike GetColliders(Cuboidd, int, List<Collider>, CollisionQueryFilter?), this method keeps no caller state and stops at the first hit, so concurrent calls are safe.
bool IntersectsAny(Cuboidd bounds, int dimension, bool alsoCheckTouch = true, CollisionQueryFilter? filter = null)
Parameters
boundsCuboidddimensionintalsoCheckTouchboolfilterCollisionQueryFilter?
Returns
IntersectsAny(TransformedCuboidd, int, bool, CollisionQueryFilter?)
Tests the exact boxes of the registered colliders against a transformed cuboid. The query box must not be mutated until this call returns.
bool IntersectsAny(TransformedCuboidd box, int dimension, bool alsoCheckTouch = true, CollisionQueryFilter? filter = null)
Parameters
boxTransformedCuboidddimensionintalsoCheckTouchboolfilterCollisionQueryFilter?
Returns
Raycast(FastVec3d, FastVec3d, int, List<CollisionHit>, CollisionQueryFilter?, bool)
Casts a finite ray from origin to origin plus displacement using the shared sweep hit contract. The displacement need not be normalized. A zero displacement tests whether the origin is inside a box.
void Raycast(FastVec3d origin, FastVec3d displacement, int dimension, List<CollisionHit> results, CollisionQueryFilter? filter = null, bool includeInitialOverlap = true)
Parameters
originFastVec3ddisplacementFastVec3ddimensionintresultsList<CollisionHit>filterCollisionQueryFilter?includeInitialOverlapbool
RegisterCollider(int, IReadOnlyList<Cuboidd>, BlockPos?, IReadOnlyList<int>?, CollisionLayer, CollisionLayer)
Registers a persistent solid collider. The supplied boxes use dimension-local world coordinates and are copied by the scene. Supplying a selection position makes the boxes selectable as that block. Selection indices default to the collision-box order.
long RegisterCollider(int dimension, IReadOnlyList<Cuboidd> collisionBoxes, BlockPos? selectionPosition = null, IReadOnlyList<int>? selectionBoxIndices = null, CollisionLayer collisionLayer = CollisionLayer.Solid, CollisionLayer collisionMask = (CollisionLayer)18446744073709551615)
Parameters
dimensionintcollisionBoxesIReadOnlyList<Cuboidd>selectionPositionBlockPosselectionBoxIndicesIReadOnlyList<int>collisionLayerCollisionLayercollisionMaskCollisionLayer
Returns
RegisterTransformedCollider(int, IReadOnlyList<Cuboidd>, ColliderTransform, bool, long, string?, bool, CollisionLayer, CollisionLayer, BlockPos?, IReadOnlyList<int>?)
Registers a collider whose boxes use collider-local coordinates.
Updating its transform reuses that registered geometry. Colliders which carry entities can be used as moving platforms or floors.
The owning entity's physics will ignore the collider when ownerEntityId is nonzero.
An owner collider code can identify that local registration on the client and server through IEntityColliderProvider.
keepsSupportedEntitiesDry prevents overlapping block liquid from affecting an entity while this collider supports it.
Supplying a selection position makes the transformed boxes selectable as that block.
long RegisterTransformedCollider(int dimension, IReadOnlyList<Cuboidd> localCollisionBoxes, ColliderTransform transform, bool canCarryEntities = false, long ownerEntityId = 0, string? ownerColliderCode = null, bool keepsSupportedEntitiesDry = false, CollisionLayer collisionLayer = CollisionLayer.Solid, CollisionLayer collisionMask = (CollisionLayer)18446744073709551615, BlockPos? selectionPosition = null, IReadOnlyList<int>? selectionBoxIndices = null)
Parameters
dimensionintlocalCollisionBoxesIReadOnlyList<Cuboidd>transformColliderTransformcanCarryEntitiesboolownerEntityIdlongownerColliderCodestringkeepsSupportedEntitiesDryboolcollisionLayerCollisionLayercollisionMaskCollisionLayerselectionPositionBlockPosselectionBoxIndicesIReadOnlyList<int>
Returns
Sweep(Cuboidd, double, double, double, int, List<CollisionHit>, CollisionQueryFilter?, bool)
void Sweep(Cuboidd box, double motionX, double motionY, double motionZ, int dimension, List<CollisionHit> results, CollisionQueryFilter? filter = null, bool includeInitialOverlap = true)
Parameters
boxCuboiddmotionXdoublemotionYdoublemotionZdoubledimensionintresultsList<CollisionHit>filterCollisionQueryFilter?includeInitialOverlapbool
Sweep(TransformedCuboidd, double, double, double, int, List<CollisionHit>, CollisionQueryFilter?, bool)
Replaces the caller-owned list with one hit per collision box, ordered by fraction, collider ID, then box index. Sweeps translation against current snapshots without sweeping target motion or query rotation. Initial strict overlaps are included by default. Motion along or away from a touching surface is ignored. The query box must not be mutated until the call returns.
void Sweep(TransformedCuboidd box, double motionX, double motionY, double motionZ, int dimension, List<CollisionHit> results, CollisionQueryFilter? filter = null, bool includeInitialOverlap = true)
Parameters
boxTransformedCuboiddmotionXdoublemotionYdoublemotionZdoubledimensionintresultsList<CollisionHit>filterCollisionQueryFilter?includeInitialOverlapbool
TryGetCollider(long, string, out Collider?)
Resolves an entity's unique collider code to its current local snapshot.
bool TryGetCollider(long ownerEntityId, string ownerColliderCode, out Collider? collider)
Parameters
Returns
TryGetCollider(long, out Collider?)
Gets the current immutable snapshot of a registered collider.
bool TryGetCollider(long colliderId, out Collider? collider)
Parameters
Returns
UnregisterCollider(long)
Removes a registered collider.
bool UnregisterCollider(long colliderId)
Parameters
colliderIdlong
Returns
UnregisterEntityColliders(long)
Removes every collider registered to this entity, including registrations without a collider code. Returns the number removed. Entity despawn calls this after the owner callbacks on both client and server.
int UnregisterEntityColliders(long ownerEntityId)
Parameters
ownerEntityIdlong
Returns
UpdateCollider(long, int, IReadOnlyList<Cuboidd>, BlockPos?, IReadOnlyList<int>?, CollisionLayer?, CollisionLayer?)
Replaces the dimension, boxes, and optional block-selection metadata of a registered collider. Filtering is retained unless supplied. Replacing a transformed collider removes its transform and entity-owner metadata.
bool UpdateCollider(long colliderId, int dimension, IReadOnlyList<Cuboidd> collisionBoxes, BlockPos? selectionPosition = null, IReadOnlyList<int>? selectionBoxIndices = null, CollisionLayer? collisionLayer = null, CollisionLayer? collisionMask = null)
Parameters
colliderIdlongdimensionintcollisionBoxesIReadOnlyList<Cuboidd>selectionPositionBlockPosselectionBoxIndicesIReadOnlyList<int>collisionLayerCollisionLayer?collisionMaskCollisionLayer?
Returns
UpdateColliderFilter(long, CollisionLayer, CollisionLayer)
bool UpdateColliderFilter(long colliderId, CollisionLayer collisionLayer, CollisionLayer collisionMask)
Parameters
colliderIdlongcollisionLayerCollisionLayercollisionMaskCollisionLayer
Returns
UpdateColliderTransform(long, int, ColliderTransform, double)
Updates the dimension and transform of a transformed collider without replacing its local geometry.
elapsedSeconds is the time since the previous transform and is used to derive point velocity for carrying entities.
It will pass zero when velocity is not known.
Block-selection metadata is retained and must remain in the collider's dimension.
bool UpdateColliderTransform(long colliderId, int dimension, ColliderTransform transform, double elapsedSeconds = 0)
Parameters
colliderIdlongdimensioninttransformColliderTransformelapsedSecondsdouble