Nebula
Loading...
Searching...
No Matches
PhysicsFeature::ScriptApi Namespace Reference

Functions

static Physics::ActorId ResolveActor (uint32_t actorId)
 An actor id a script hands in is not one this side resolved, so it has to be checked against the pool before it is used.
static PxRigidDynamic * ResolveDynamic (Physics::ActorId id)
 The dynamic body of an actor.
bool Physics_IsActorValid (uint32_t actorId)
float Physics_GetMass (uint32_t actorId)
 The mass the body actually has.
bool Physics_IsSleeping (uint32_t actorId)
void Physics_WakeUp (uint32_t actorId)
void Physics_Sleep (uint32_t actorId)
Math::vec3 Physics_GetVelocity (uint32_t actorId)
void Physics_SetVelocity (uint32_t actorId, Math::vec3 velocity)
Math::vec3 Physics_GetAngularVelocity (uint32_t actorId)
void Physics_SetAngularVelocity (uint32_t actorId, Math::vec3 angularVelocity)
void Physics_AddForce (uint32_t actorId, Math::vec3 force)
 Newtons.
void Physics_AddImpulse (uint32_t actorId, Math::vec3 impulse)
void Physics_AddImpulseAtPoint (uint32_t actorId, Math::vec3 impulse, Math::vec3 point)
 An impulse at a point also gives the body angular velocity, which is why this goes through the extension rather than the body.
void Physics_AddTorque (uint32_t actorId, Math::vec3 torque)
uint32_t Physics_GetSceneForWorld (uint32_t worldId)
static void CopyHit (const Physics::RaycastHit &hit, PhysicsFeature::RaycastHit *outHit)
 Write a hit into the buffer the managed side owns.
static void CopyShapeCastHit (const Physics::ShapeCastHit &hit, PhysicsFeature::ShapeCastHit *outHit)
 Write a shape cast hit into the buffer the managed side owns.
static Physics::QueryFilter ResolveFilter (const PhysicsFeature::QueryFilter *filter)
 The filter arrives as a pointer because a blittable managed struct passed with ref is a pointer on this side.
bool Physics_Raycast (uint32_t scene, Math::point origin, Math::vector direction, float maxDistance, PhysicsFeature::RaycastHit *outHit, const PhysicsFeature::QueryFilter *filter)
bool Physics_SegmentCast (uint32_t scene, Math::point from, Math::point to, PhysicsFeature::RaycastHit *outHit, const PhysicsFeature::QueryFilter *filter)
bool Physics_SphereCast (uint32_t scene, Math::point center, float radius, Math::vector direction, float maxDistance, PhysicsFeature::ShapeCastHit *outHit, const PhysicsFeature::QueryFilter *filter)
bool Physics_SphereCastAny (uint32_t scene, Math::point center, float radius, Math::vector direction, float maxDistance, PhysicsFeature::ShapeCastHit *outHit, const PhysicsFeature::QueryFilter *filter)
 The first hit found along a swept sphere, which is not necessarily the closest.
bool Physics_BoxCast (uint32_t scene, Math::point center, Math::quat orientation, Math::vec3 halfExtents, Math::vector direction, float maxDistance, PhysicsFeature::ShapeCastHit *outHit, const PhysicsFeature::QueryFilter *filter)
bool Physics_BoxCastAny (uint32_t scene, Math::point center, Math::quat orientation, Math::vec3 halfExtents, Math::vector direction, float maxDistance, PhysicsFeature::ShapeCastHit *outHit, const PhysicsFeature::QueryFilter *filter)
 The first hit found along a swept box, which is not necessarily the closest.
static Physics::CharacterId ResolveCharacter (uint32_t characterId)
bool Physics_IsCharacterValid (uint32_t characterId)
Math::vec3 Physics_GetCharacterFootPosition (uint32_t characterId)
Math::vec3 Physics_GetCharacterCenterPosition (uint32_t characterId)
uint32_t Physics_MoveCharacter (uint32_t characterId, Math::vec3 displacement, float minDist, float timeSinceLastMove)
 The collision bits as a plain number, because the managed side has no mirror of the engine's bitfield.
void Physics_SetCharacterPosition (uint32_t characterId, Math::vec3 footPosition)
 A teleport, which is what PhysX documents this as: it does not check for collisions.
void Physics_SetCharacterHeight (uint32_t characterId, float newHeight)

Function Documentation

◆ CopyHit()

void PhysicsFeature::ScriptApi::CopyHit ( const Physics::RaycastHit & hit,
PhysicsFeature::RaycastHit * outHit )
static

Write a hit into the buffer the managed side owns.

The fields are assigned one at a time rather than by copying the struct, because the two sides only share the field order, not the types. The managed mirror has Vector3 where this side has the 16 byte aligned math types, and a managed buffer has no alignment guarantee.

◆ CopyShapeCastHit()

void PhysicsFeature::ScriptApi::CopyShapeCastHit ( const Physics::ShapeCastHit & hit,
PhysicsFeature::ShapeCastHit * outHit )
static

Write a shape cast hit into the buffer the managed side owns.

◆ Physics_AddForce()

NEBULA_EXPORT void PhysicsFeature::ScriptApi::Physics_AddForce ( uint32_t actorId,
Math::vec3 force )

Newtons.

The mode is what makes a force and an impulse different quantities here: a force is integrated by the step, an impulse is the velocity change the step applies to the body

◆ Physics_AddImpulse()

NEBULA_EXPORT void PhysicsFeature::ScriptApi::Physics_AddImpulse ( uint32_t actorId,
Math::vec3 impulse )

◆ Physics_AddImpulseAtPoint()

NEBULA_EXPORT void PhysicsFeature::ScriptApi::Physics_AddImpulseAtPoint ( uint32_t actorId,
Math::vec3 impulse,
Math::vec3 point )

An impulse at a point also gives the body angular velocity, which is why this goes through the extension rather than the body.

◆ Physics_AddTorque()

NEBULA_EXPORT void PhysicsFeature::ScriptApi::Physics_AddTorque ( uint32_t actorId,
Math::vec3 torque )

◆ Physics_BoxCast()

NEBULA_EXPORT bool PhysicsFeature::ScriptApi::Physics_BoxCast ( uint32_t scene,
Math::point center,
Math::quat orientation,
Math::vec3 halfExtents,
Math::vector direction,
float maxDistance,
PhysicsFeature::ShapeCastHit * outHit,
const PhysicsFeature::QueryFilter * filter )

◆ Physics_BoxCastAny()

NEBULA_EXPORT bool PhysicsFeature::ScriptApi::Physics_BoxCastAny ( uint32_t scene,
Math::point center,
Math::quat orientation,
Math::vec3 halfExtents,
Math::vector direction,
float maxDistance,
PhysicsFeature::ShapeCastHit * outHit,
const PhysicsFeature::QueryFilter * filter )

The first hit found along a swept box, which is not necessarily the closest.

◆ Physics_GetAngularVelocity()

NEBULA_EXPORT Math::vec3 PhysicsFeature::ScriptApi::Physics_GetAngularVelocity ( uint32_t actorId)

◆ Physics_GetCharacterCenterPosition()

NEBULA_EXPORT Math::vec3 PhysicsFeature::ScriptApi::Physics_GetCharacterCenterPosition ( uint32_t characterId)

◆ Physics_GetCharacterFootPosition()

NEBULA_EXPORT Math::vec3 PhysicsFeature::ScriptApi::Physics_GetCharacterFootPosition ( uint32_t characterId)

◆ Physics_GetMass()

NEBULA_EXPORT float PhysicsFeature::ScriptApi::Physics_GetMass ( uint32_t actorId)

The mass the body actually has.

The Rigidbody component's mass is 0 when it is derived from the shape volumes and the material densities, so reading the component is not the same as reading the body

◆ Physics_GetSceneForWorld()

NEBULA_EXPORT uint32_t PhysicsFeature::ScriptApi::Physics_GetSceneForWorld ( uint32_t worldId)

◆ Physics_GetVelocity()

NEBULA_EXPORT Math::vec3 PhysicsFeature::ScriptApi::Physics_GetVelocity ( uint32_t actorId)

◆ Physics_IsActorValid()

NEBULA_EXPORT bool PhysicsFeature::ScriptApi::Physics_IsActorValid ( uint32_t actorId)

◆ Physics_IsCharacterValid()

NEBULA_EXPORT bool PhysicsFeature::ScriptApi::Physics_IsCharacterValid ( uint32_t characterId)

◆ Physics_IsSleeping()

NEBULA_EXPORT bool PhysicsFeature::ScriptApi::Physics_IsSleeping ( uint32_t actorId)

◆ Physics_MoveCharacter()

NEBULA_EXPORT uint32_t PhysicsFeature::ScriptApi::Physics_MoveCharacter ( uint32_t characterId,
Math::vec3 displacement,
float minDist,
float timeSinceLastMove )

The collision bits as a plain number, because the managed side has no mirror of the engine's bitfield.

The collision bits the move answered with, as a bitfield: bit 0 sides, bit 1 up, bit 2 down.

A character which is not in the pool answers with zero, which is no collision.

◆ Physics_Raycast()

NEBULA_EXPORT bool PhysicsFeature::ScriptApi::Physics_Raycast ( uint32_t scene,
Math::point origin,
Math::vector direction,
float maxDistance,
PhysicsFeature::RaycastHit * outHit,
const PhysicsFeature::QueryFilter * filter )

◆ Physics_SegmentCast()

NEBULA_EXPORT bool PhysicsFeature::ScriptApi::Physics_SegmentCast ( uint32_t scene,
Math::point from,
Math::point to,
PhysicsFeature::RaycastHit * outHit,
const PhysicsFeature::QueryFilter * filter )

◆ Physics_SetAngularVelocity()

NEBULA_EXPORT void PhysicsFeature::ScriptApi::Physics_SetAngularVelocity ( uint32_t actorId,
Math::vec3 angularVelocity )

◆ Physics_SetCharacterHeight()

NEBULA_EXPORT void PhysicsFeature::ScriptApi::Physics_SetCharacterHeight ( uint32_t characterId,
float newHeight )

◆ Physics_SetCharacterPosition()

NEBULA_EXPORT void PhysicsFeature::ScriptApi::Physics_SetCharacterPosition ( uint32_t characterId,
Math::vec3 footPosition )

A teleport, which is what PhysX documents this as: it does not check for collisions.

The position is the foot, which is the same thing the entity's Position component holds

◆ Physics_SetVelocity()

NEBULA_EXPORT void PhysicsFeature::ScriptApi::Physics_SetVelocity ( uint32_t actorId,
Math::vec3 velocity )

◆ Physics_Sleep()

NEBULA_EXPORT void PhysicsFeature::ScriptApi::Physics_Sleep ( uint32_t actorId)

◆ Physics_SphereCast()

NEBULA_EXPORT bool PhysicsFeature::ScriptApi::Physics_SphereCast ( uint32_t scene,
Math::point center,
float radius,
Math::vector direction,
float maxDistance,
PhysicsFeature::ShapeCastHit * outHit,
const PhysicsFeature::QueryFilter * filter )

◆ Physics_SphereCastAny()

NEBULA_EXPORT bool PhysicsFeature::ScriptApi::Physics_SphereCastAny ( uint32_t scene,
Math::point center,
float radius,
Math::vector direction,
float maxDistance,
PhysicsFeature::ShapeCastHit * outHit,
const PhysicsFeature::QueryFilter * filter )

The first hit found along a swept sphere, which is not necessarily the closest.

◆ Physics_WakeUp()

NEBULA_EXPORT void PhysicsFeature::ScriptApi::Physics_WakeUp ( uint32_t actorId)

◆ ResolveActor()

Physics::ActorId PhysicsFeature::ScriptApi::ResolveActor ( uint32_t actorId)
static

An actor id a script hands in is not one this side resolved, so it has to be checked against the pool before it is used.

A script can hold an id across a rebuild, and the entity the id named can be gone by the time the call comes back

◆ ResolveCharacter()

Physics::CharacterId PhysicsFeature::ScriptApi::ResolveCharacter ( uint32_t characterId)
static

◆ ResolveDynamic()

PxRigidDynamic * PhysicsFeature::ScriptApi::ResolveDynamic ( Physics::ActorId id)
static

The dynamic body of an actor.

Velocity and the sleep state only exist on a dynamic body, so a static or kinematic one answers with null and the call does nothing

◆ ResolveFilter()

Physics::QueryFilter PhysicsFeature::ScriptApi::ResolveFilter ( const PhysicsFeature::QueryFilter * filter)
static

The filter arrives as a pointer because a blittable managed struct passed with ref is a pointer on this side.

The excluded actor is named by an id the managed side holds, so it has to be resolved against the pool before the query uses it