Nebula
Loading...
Searching...
No Matches
actorcontext.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
9//------------------------------------------------------------------------------
10
11#include "physicsinterface.h"
13#include "math/vector.h"
14#include "math/plane.h"
15#include "math/mat4.h"
16#include "util/tupleutility.h"
17#include "math/transform.h"
18
19namespace Physics
20{
21
23{
24 ShapeHandle() : shape(nullptr) {}
25 explicit ShapeHandle(physx::PxShape* inShape) : shape(inShape) {}
26 bool IsValid() const { return shape != nullptr; }
27 bool operator==(const ShapeHandle& other) { return shape == other.shape; }
28 physx::PxShape* shape;
29};
30
31class PhysxState;
32class StreamActorPool;
33
35{
36public:
39 static ActorId CreateBox(Math::vector const& extends, IndexT material, ActorType type, Math::mat4 const & transform, IndexT scene = 0);
41 static ActorId CreateSphere(float radius, IndexT material, ActorType type, Math::mat4 const & transform, IndexT scene = 0);
43 static ActorId CreatePlane(Math::plane const& plane, IndexT material, IndexT scene = 0);
45 static ActorId CreateCapsule(float radius, float halfHeight, IndexT material, ActorType type, Math::mat4 const & transform, IndexT scene = 0);
46
48 static Actor& GetActor(ActorId id);
50 static void SetTransform(ActorId id, Math::mat4 const & transform);
54 static void SetPositionOrientation(ActorId id, Math::vec3 const& position, Math::quat const& orientation);
56 static void GetPositionOrientation(ActorId id, Math::vec3& position, Math::quat& orientation);
57
59 static void SetLinearVelocity(ActorId id, Math::vector speed);
62
64 static void SetAngularVelocity(ActorId id, Math::vector speed);
67
69 static void ApplyImpulseAtPos(ActorId id, const Math::vector& impulse, const Math::point& pos);
70
72 static void SetCollisionFeedback(ActorId id, CollisionFeedback feedback);
73
74 // shape stuff
75 enum { DefaultShapeAlloc = 16 };
77 static SizeT GetShapeCount(ActorId id);
78 static void GetShapes(ActorId id, ShapeArrayType& shapes);
79
81 static void SetShapeTransform(const ShapeHandle& shape, const Math::transform& transform);
82
83
85 static physx::PxRigidActor* GetPxActor(ActorId id);
87 static physx::PxRigidDynamic* GetPxDynamic(ActorId id);
88
89 static bool IsValid(ActorId id);
90
91 friend class PhysxState;
92 friend class StreamActorPool;
93private:
97 static ActorId AllocateActorId(physx::PxRigidActor* pxActor);
99 static ActorId AllocateActorId(physx::PxRigidActor* pxActor, ActorResourceId res);
101 static void DiscardActor(ActorId id);
102};
103
105{
106public:
108
109 friend class PhysxState;
110 friend class StreamActorPool;
111private:
117 static void DiscardAggregate(AggregateId id);
118};
119
120//------------------------------------------------------------------------------
123inline bool
128
129}
Provides a system for creating array friendly id numbers with reuse and generations.
Definition idgenerationpool.h:43
bool IsValid(Id32 id) const
check if valid
Definition idgenerationpool.cc:66
Simple transform using position, quaternion, and scale.
Definition transform.h:18
Definition actorcontext.h:35
static void DiscardActor(ActorId id)
Definition actorcontext.cc:62
static void SetCollisionFeedback(ActorId id, CollisionFeedback feedback)
modify collision callback handling
Definition actorcontext.cc:358
static ActorId CreateCapsule(float radius, float halfHeight, IndexT material, ActorType type, Math::mat4 const &transform, IndexT scene=0)
Definition actorcontext.cc:122
static void ApplyImpulseAtPos(ActorId id, const Math::vector &impulse, const Math::point &pos)
apply a global impulse vector at the next time step at a global position
Definition actorcontext.cc:271
static ActorId CreateBox(Math::vector const &extends, IndexT material, ActorType type, Math::mat4 const &transform, IndexT scene=0)
helper functions for creating shapes
Definition actorcontext.cc:80
static ActorId CreatePlane(Math::plane const &plane, IndexT material, IndexT scene=0)
Definition actorcontext.cc:142
static void GetPositionOrientation(ActorId id, Math::vec3 &position, Math::quat &orientation)
Definition actorcontext.cc:219
static Math::vector GetLinearVelocity(ActorId id)
Definition actorcontext.cc:241
static Ids::IdGenerationPool actorPool
Definition actorcontext.h:95
static physx::PxRigidDynamic * GetPxDynamic(ActorId id)
shortcut for getting the pxactor object
Definition actorcontext.cc:292
static Util::Array< Actor > actors
Definition actorcontext.h:94
static ActorId AllocateActorId(physx::PxRigidActor *pxActor, ActorResourceId res)
static Actor & GetActor(ActorId id)
Definition actorcontext.cc:164
static void SetPositionOrientation(ActorId id, Math::vec3 const &position, Math::quat const &orientation)
Definition actorcontext.cc:201
@ DefaultShapeAlloc
Definition actorcontext.h:75
static void GetShapes(ActorId id, ShapeArrayType &shapes)
Definition actorcontext.cc:318
static Math::mat4 GetTransform(ActorId id)
Definition actorcontext.cc:191
static void SetShapeTransform(const ShapeHandle &shape, const Math::transform &transform)
Definition actorcontext.cc:347
static ActorId AllocateActorId(physx::PxRigidActor *pxActor)
static bool IsValid(ActorId id)
Definition actorcontext.h:124
static Math::transform GetShapeTransform(const ShapeHandle &shape)
Definition actorcontext.cc:338
static void SetTransform(ActorId id, Math::mat4 const &transform)
Definition actorcontext.cc:173
static void SetAngularVelocity(ActorId id, Math::vector speed)
Definition actorcontext.cc:251
static ActorId CreateSphere(float radius, IndexT material, ActorType type, Math::mat4 const &transform, IndexT scene=0)
Definition actorcontext.cc:101
static void SetLinearVelocity(ActorId id, Math::vector speed)
Definition actorcontext.cc:231
static Math::vector GetAngularVelocity(ActorId id)
Definition actorcontext.cc:261
static SizeT GetShapeCount(ActorId id)
Definition actorcontext.cc:302
static physx::PxRigidActor * GetPxActor(ActorId id)
shortcut for getting the pxactor object
Definition actorcontext.cc:282
Definition actorcontext.h:105
static AggregateId AllocateAggregateId(AggregateResourceId res)
Definition actorcontext.cc:385
static Ids::IdGenerationPool aggPool
Definition actorcontext.h:113
static Aggregate & GetAggregate(AggregateId id)
Definition actorcontext.cc:406
static void DiscardAggregate(AggregateId id)
Definition actorcontext.cc:417
static Util::Array< Aggregate > aggregates
Definition actorcontext.h:112
Definition physxstate.h:25
Definition streamactorpool.h:65
Nebula's dynamic array class.
Definition array.h:60
Diverse functions for manipulating physics actors.
Definition actorcontext.cc:18
ActorType
Definition physicsinterface.h:35
A 4x4 single point precision float matrix.
Definition mat4.h:49
A mathematical plane represented by a normal and a distance from origin.
Definition plane.h:22
Represents a 3D point in space.
Definition point.h:22
A quaternion is usually used to represent an orientation in 3D space.
Definition quat.h:30
A 3D vector.
Definition vec3.h:40
A vector is a 3D direction in space.
Definition vector.h:22
Definition physicsinterface.h:71
Definition physicsinterface.h:50
Definition physicsinterface.h:29
Definition physicsinterface.h:90
Definition physicsinterface.h:64
Definition physicsinterface.h:30
Definition actorcontext.h:23
ShapeHandle(physx::PxShape *inShape)
Definition actorcontext.h:25
bool IsValid() const
Definition actorcontext.h:26
ShapeHandle()
Definition actorcontext.h:24
bool operator==(const ShapeHandle &other)
Definition actorcontext.h:27
physx::PxShape * shape
Definition actorcontext.h:28
int SizeT
Definition types.h:49
int IndexT
Definition types.h:48