![]() |
CUGL 2.5
Cornell University Game Library
|
#include <CUPhysObstEvent.h>
Classes | |
class | BoolConsts |
class | FloatConsts |
Public Types | |
enum class | EventType : int { UNKNOWN = 0 , CREATION = 1 , DELETION = 2 , BODY_TYPE = 3 , POSITION = 4 , VELOCITY = 5 , ANGLE = 6 , ANGULAR_VEL = 7 , BOOL_CONSTS = 8 , FLOAT_CONSTS = 9 , OWNER_ACQUIRE = 10 , OWNER_RELEASE = 11 } |
Public Member Functions | |
EventType | getType () const |
Uint64 | getObstacleId () const |
Uint32 | getFactoryId () const |
const std::shared_ptr< std::vector< std::byte > > | getPackedParam () const |
void | initCreation (Uint32 factoryId, Uint64 obsId, std::shared_ptr< std::vector< std::byte > > packedParam) |
void | initDeletion (Uint64 obsId) |
void | initPos (Uint64 obsId, Vec2 pos) |
void | initVel (Uint64 obsId, Vec2 vel) |
void | initAngle (Uint64 obsId, float angle) |
void | initAngularVel (Uint64 obsId, float angularVel) |
void | initBodyType (Uint64 obsId, b2BodyType bodyType) |
void | initBoolConsts (Uint64 obsId, const BoolConsts &values) |
void | initFloatConsts (Uint64 obsId, const FloatConsts &values) |
void | initOwnerAcquire (Uint64 obsId, Uint64 duration) |
void | initOwnerRelease (Uint64 obsId) |
std::shared_ptr< NetEvent > | newEvent () override |
const b2BodyType | getBodyType () const |
const Vec2 | getPosition () const |
const Vec2 | getLinearVelocity () const |
float | getAngle () const |
const float | getAngularVelocity () const |
bool | isEnabled () const |
bool | isAwake () const |
bool | isSleepingAllowed () const |
bool | isBullet () const |
bool | isFixedRotation () const |
float | getGravityScale () const |
float | getLinearDamping () const |
float | getAngularDamping () const |
float | getDensity () const |
float | getFriction () const |
float | getRestitution () const |
bool | isSensor () const |
const Vec2 | getCentroid () const |
float | getInertia () const |
float | getMass () const |
std::vector< std::byte > | serialize () override |
void | deserialize (const std::vector< std::byte > &data) override |
![]() | |
virtual std::shared_ptr< NetEvent > | newEvent () |
virtual std::vector< std::byte > | serialize () |
virtual void | deserialize (const std::vector< std::byte > &data) |
Uint64 | getEventTimeStamp () const |
Uint64 | getReceiveTimeStamp () const |
const std::string | getSourceId () const |
Static Public Member Functions | |
static std::shared_ptr< PhysObstEvent > | allocCreation (Uint32 factoryId, Uint64 obsId, std::shared_ptr< std::vector< std::byte > > packedParam) |
static std::shared_ptr< PhysObstEvent > | allocDeletion (Uint64 obsId) |
static std::shared_ptr< PhysObstEvent > | allocPos (Uint64 obsId, Vec2 pos) |
static std::shared_ptr< PhysObstEvent > | allocVel (Uint64 obsId, Vec2 vel) |
static std::shared_ptr< PhysObstEvent > | allocAngle (Uint64 obsId, float angle) |
static std::shared_ptr< PhysObstEvent > | allocAngularVel (Uint64 obsId, float angularVel) |
static std::shared_ptr< PhysObstEvent > | allocBodyType (Uint64 obsId, b2BodyType bodyType) |
static std::shared_ptr< PhysObstEvent > | allocBoolConsts (Uint64 obsId, const BoolConsts &values) |
static std::shared_ptr< PhysObstEvent > | allocFloatConsts (Uint64 obsId, const FloatConsts &values) |
static std::shared_ptr< PhysObstEvent > | allocOwnerAcquire (Uint64 obsId, Uint64 duration) |
static std::shared_ptr< PhysObstEvent > | allocOwnerRelease (Uint64 obsId) |
Protected Attributes | |
EventType | _type |
Uint64 | _obstacleId |
Uint32 | _factoryId |
std::shared_ptr< std::vector< std::byte > > | _packedParam |
Vec2 | _pos |
Vec2 | _vel |
float | _angle |
float | _angularVel |
bool | _isStatic |
bool | _isEnabled |
bool | _isAwake |
bool | _isSleepingAllowed |
bool | _isFixedRotation |
bool | _isBullet |
bool | _isSensor |
float | _density |
float | _friction |
float | _restitution |
float | _linearDamping |
float | _angularDamping |
float | _gravityScale |
float | _mass |
float | _inertia |
Vec2 | _centroid |
b2BodyType | _bodyType |
Uint64 | _duration |
LWSerializer | _serializer |
LWDeserializer | _deserializer |
This class represents an event for an obstacle state change.
These events are created when the user sets the position or velocity manually, outside of the simulation. It includes all changes to the object state.
Instances of this class will be created automatically by the physics world and gathered by the network controller.
|
strong |
Enum for the type of the event.
|
inlinestatic |
Returns a newly created EventType::ANGLE
event.
This method is a shortcut for creating a shared object on initAngle
.
obsId | The obstacle global id |
angle | The obstacle angle |
EventType::ANGLE
event.
|
inlinestatic |
Returns a newly created EventType::ANGULAR_VEL
event.
This method is a shortcut for creating a shared object on initAngularVel
.
obsId | The obstacle global id |
angularVel | The anglular velocity |
EventType::ANGULAR_VEL
event.
|
inlinestatic |
Returns a newly created EventType::BODY_TYPE
event.
This method is a shortcut for creating a shared object on initBodyType
.
obsId | The obstacle global id |
bodyType | The obstacle body type |
EventType::BODY_TYPE
event.
|
inlinestatic |
Returns a newly created EventType::BOOL_CONSTS
event.
This method is a shortcut for creating a shared object on initBoolConsts
.
obsId | The obstacle global id |
values | The boolean constants |
EventType::BOOL_CONSTS
event.
|
inlinestatic |
Returns a newly created EventType::CREATION
event.
This method is a shortcut for creating a shared object on initCreation
.
factoryId | The obstacle factory id |
obsId | The obstacle global id |
packedParam | The packed parameters for the obstacle |
EventType::CREATION
event.
|
inlinestatic |
Returns a newly created EventType::DELETION
event.
This method is a shortcut for creating a shared object on initDeletion
.
obsId | The obstacle global id |
EventType::DELETION
event.
|
inlinestatic |
Returns a newly created EventType::FLOAT_CONSTS
event.
This method is a shortcut for creating a shared object on initFloatConsts
.
obsId | The obstacle global id |
values | The boolean constants |
EventType::FLOAT_CONSTS
event.
|
inlinestatic |
Returns a newly created EventType::OWNER_ACQUIRE
event.
This method is a shortcut for creating a shared object on initOwnerAcquire
.
obsId | The obstacle global id |
duration | The length of time to acquire the obstacle. |
EventType::OWNER_ACQUIRE
event.
|
inlinestatic |
Returns a newly created EventType::OWNER_RELEASE
event.
This method is a shortcut for creating a shared object on initOwnerRelease
.
obsId | The obstacle global id |
EventType::OWNER_RELEASE
event.
|
inlinestatic |
Returns a newly created EventType::POSITION
event.
This method is a shortcut for creating a shared object on initPos
.
obsId | The obstacle global id |
pos | The obstacle position |
EventType::POSITION
event.
|
inlinestatic |
Returns a newly created EventType::VELOCITY
event.
This method is a shortcut for creating a shared object on initVel
.
obsId | The obstacle global id |
vel | The obstacle velocity |
EventType::VELOCITY
event.
|
overridevirtual |
Deserializes this event from a byte vector.
This method will set the type of the event and all relevant fields.
Reimplemented from cugl::physics2::net::NetEvent.
|
inline |
Returns the angle for this physics event
The value returned is in radians
|
inline |
Returns the angular damping for this physics event.
|
inline |
Returns the angular velocity for this physics event
|
inline |
Returns the body type for this physics event
|
inline |
Returns the center of mass of this physics event.
|
inline |
Returns the density of this physics event.
The density is typically measured in usually in kg/m^2. The density can be zero or positive. You should generally use similar densities for all your fixtures. This will improve stacking stability.
|
inline |
Returns the obstacle factory id of this event.
This only valid for EventType#CREATION
events.
|
inline |
Returns the friction coefficient of this physics event.
The friction parameter is usually set between 0 and 1, but can be any non-negative value. A friction value of 0 turns off friction and a value of 1 makes the friction strong. When the friction force is computed between two shapes, Box2D must combine the friction parameters of the two parent fixtures. This is done with the geometric mean.
|
inline |
Returns the gravity scale to apply to this physics event
|
inline |
Returns the rotational inertia of this physics event.
|
inline |
Returns the linear damping for this physics event.
|
inline |
Returns the linear velocity for this physics event
|
inline |
Returns the mass of this physics event.
|
inline |
Returns the obstacle global id of this event.
|
inline |
Returns the packed parameters for creating the obstacle.
This only valid for EventType#CREATION
events.
|
inline |
Returns the position for this physics event
|
inline |
Returns the restitution of this physics event.
Restitution is used to make objects bounce. The restitution value is usually set to be between 0 and 1. Consider dropping a ball on a table. A value of zero means the ball won't bounce. This is called an inelastic collision. A value of one means the ball's velocity will be exactly reflected. This is called a perfectly elastic collision.
|
inline |
Returns the type of this event.
|
inline |
Initializes an empty event to EventType#ANGLE
.
This event symbolizes a change in the angle of an obstacle.
obsId | The obstacle global id |
angle | The obstacle angle |
|
inline |
Initializes an empty event to EventType#ANGULAR_VEL
.
This event symbolizes a change in the anglular velocity of an obstacle.
obsId | The obstacle global id |
angularVel | The angular velocity |
|
inline |
Initializes an empty event to EventType#BODY_TYPE
.
This event symbolizes a change in the body type of an obstacle.
obsId | The obstacle global id |
bodyType | The body type |
|
inline |
Initializes an empty event to EventType#BOOL_CONSTS
.
This event symbolizes a change in the boolean constants of an obstacle. Due to the relatively rarer use of these constants, they are packed into a single event.
obsId | The obstacle global id |
values | The boolean constants |
|
inline |
Initializes an empty event as EventType#CREATION
.
This event symbolizes the creation of an obstacle.
factoryId | The obstacle factory id |
obsId | The obstacle global id |
packedParam | The packed parameters for the obstacle |
|
inline |
Initializes an empty event to EventType#DELETION
.
This event symbolizes the deletion of an obstacle.
obsId | The obstacle global id |
|
inline |
Initializes an empty event to EventType::FLOAT_CONSTS
.
This event symbolizes a change in the additional float constants of an obstacle. Due to the relatively rarer use of these constants, they are packed into a single event.
obsId | The obstacle global id |
values | The float constants |
|
inline |
Initializes an empty event to EventType::OWNER_ACQUIRE
.
This event symbolizes a change in obstacle ownership. Setting duration to 0 will acquire ownership permanently.
obsId | The obstacle global id |
duration | The length of time to acquire the obstacle. |
|
inline |
Initializes an empty event to EventType::OWNER_RELEASE
.
This event symbolizes a change in obstacle ownership.
obsId | The obstacle global id |
|
inline |
Initializes an empty event to EventType#POSITION
.
This event symbolizes a change in the position of an obstacle.
obsId | The obstacle global id |
pos | The obstacle position |
|
inline |
Initializes an empty event to EventType#VELOCITY
.
This event symbolizes a change in the velocity of an obstacle.
obsId | The obstacle global id |
vel | The obstacle velocity |
|
inline |
Returns true if the obstacle in this event is awake
|
inline |
Returns true if the obstacle in this event is a bullet
|
inline |
Returns true if the obstacle in this event is enabled
|
inline |
Returns true if the obstacle in this event is prevented from rotating
|
inline |
Returns true if the obstacle in this event is a sensor.
Sometimes game logic needs to know when two entities overlap yet there should be no collision response. This is done by using sensors. A sensor is an entity that detects collision but does not produce a response.
|
inline |
Returns false if the obstacle in this event should never fall asleep
|
inlineoverridevirtual |
Returns a newly allocated event of this type.
This method is used by the NetEventController to create a new event with this type as a reference.
Note that this method is not static, unlike the alloc method present in most of CUGL. That is because we need this factory method to be polymorphic. All custom subclasses must implement this method.
Reimplemented from cugl::physics2::net::NetEvent.
|
overridevirtual |
Returns a byte vector serializing this event
Reimplemented from cugl::physics2::net::NetEvent.
|
protected |
The field for EventType::ANGLE
|
protected |
The angular damping of the obstacle in this event
|
protected |
The field for EventType::ANGULAR_VEL
|
protected |
The field for OBJ_BODY_TYPE
|
protected |
The centroid of the obstacle in this event
|
protected |
The density of the obstacle in this event
|
protected |
A deserializer for unpacking data
|
protected |
The field for OBJ_OWNER_ACQUIRE
|
protected |
The obstacle factory id.
This is obtained by calling NetPhysicsController#attachFactory
.
|
protected |
The friction of the obstacle in this event
|
protected |
The gravity scale of the obstacle in this event
|
protected |
The inertia of the obstacle in this event
|
protected |
Whether the event represents an awake obstacle
|
protected |
Whether the event represents a bullet
|
protected |
Whether the event represents an enabled obstacle
|
protected |
Whether the event represents an obstacle with fixed rotation
|
protected |
Whether the event represents a sensor
|
protected |
Whether the event represents a sleepable obstacle
|
protected |
Whether the event represents a static obstacle
|
protected |
The linear damping of the obstacle in this event
|
protected |
The mass of the obstacle in this event
|
protected |
The obstacle global id.
|
protected |
The packed parameter for obstacle creation.
|
protected |
The field for EventType::POSITION
|
protected |
The restitution of the obstacle in this event
|
protected |
A serializer for packing data
|
protected |
The type of the event.
|
protected |
The field for EventType::VELOCITY