Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
CollisionProfile.h
1#pragma once
2
3#include <cstdint>
4#include <compare>
5#include <string>
6#include <vector>
7
8namespace Engine::Components
9{
10 class Collision;
11 class PhysicsBody;
12} // namespace Engine::Components
13
14namespace Engine::Entities
15{
16 class Actor;
17} // namespace Engine::Entities
18
19namespace Engine::Physics
20{
33
49
54 {
58 };
59
67 {
68 std::uint32_t id = 0;
69
74 [[nodiscard]] bool isValid() const { return id != 0; }
75
77 friend bool operator==( const CollisionProfileHandle &, const CollisionProfileHandle & ) = default;
79 friend auto operator<=>( const CollisionProfileHandle &, const CollisionProfileHandle & ) = default;
80 };
81
89 {
90 std::uint32_t id = 0;
91 std::uint32_t generation = 0;
92
97 [[nodiscard]] bool isValid() const { return id != 0 && generation != 0; }
98
100 friend bool operator==( const PhysicsBodyHandle &, const PhysicsBodyHandle & ) = default;
102 friend auto operator<=>( const PhysicsBodyHandle &, const PhysicsBodyHandle & ) = default;
103 };
104
112 {
113 std::uint32_t id = 0;
114 std::uint32_t generation = 0;
115
120 [[nodiscard]] bool isValid() const { return id != 0 && generation != 0; }
121
123 friend bool operator==( const CollisionHandle &, const CollisionHandle & ) = default;
125 friend auto operator<=>( const CollisionHandle &, const CollisionHandle & ) = default;
126 };
127
140
165
171 [[nodiscard]] const char * toString( CollisionResponse response );
172
179 [[nodiscard]] bool fromString( const std::string & value, CollisionResponse & outResponse );
180
192} // namespace Engine::Physics
Base class for collision shape components.
Component that manages a physics rigid body for an entity.
An Actor is similar to an Engine::Entities::Entity. An actor is an Entity with a transform.
Definition Actor.h:71
bool fromString(const std::string &value, CollisionResponse &outResponse)
Parses a collision response config string.
CollisionEventType
Lifetime state for a collision or overlap pair.
@ Begin
Pair was absent on the previous physics step and is present now.
@ End
Pair was present on the previous physics step and is absent or invalidated now.
@ Stay
Pair was present on the previous physics step and is still present now.
CollisionResponse resolvePairResponse(CollisionResponse responseAB, CollisionResponse responseBA)
Resolves two directed profile responses into the final pair response.
CollisionResponse
Collision response selected for a pair of collision profiles.
@ Overlap
Contact callback without physical collision response.
@ Block
Physical collision response and contact callback.
@ Ignore
No contact callback and no physical collision response.
const char * toString(CollisionResponse response)
Converts a collision response to its config string.
CollisionProfile
Built-in collision profile enum registered by CollisionProfileRegistry::registerEngineProfiles().
@ OverlapAll
Overlaps every registered profile unless a config override changes the response.
@ Pawn
Player, NPC, or agent bodies controlled by gameplay code.
@ WorldStatic
Static level geometry and non-moving world collision.
@ IgnoreAll
Ignores every registered profile unless a config override changes the response.
@ BlockAll
Blocks every registered profile unless a config override changes the response.
@ WorldDynamic
Moving world objects that are not pawns.
Actor-level collision or overlap event generated by PhysicsEngine.
Entities::Actor * otherActor
Actor that owns otherBody, when available.
std::vector< Components::Collision * > selfComponents
Collision components on selfBody that contributed to the actor-level event.
CollisionEventType eventType
Pair lifetime state for this event.
Entities::Actor * selfActor
Actor that owns selfBody, when available.
Components::PhysicsBody * selfBody
Body receiving the callback.
CollisionResponse response
Resolved response for this pair.
Components::PhysicsBody * otherBody
Counterpart body, or nullptr for invalidation End events.
std::vector< Components::Collision * > otherComponents
Collision components on otherBody that contributed to the actor-level event.
Runtime handle for a registered collision component.
friend auto operator<=>(const CollisionHandle &, const CollisionHandle &)=default
Orders collision handles by id and generation.
friend bool operator==(const CollisionHandle &, const CollisionHandle &)=default
Compares collision handles by id and generation.
bool isValid() const
Checks whether this handle contains a collision slot and generation.
std::uint32_t generation
Slot generation used to reject stale handles.
Registry handle for a collision profile name.
bool isValid() const
Checks whether this handle refers to a registered profile slot.
friend bool operator==(const CollisionProfileHandle &, const CollisionProfileHandle &)=default
Compares profile handles by id.
friend auto operator<=>(const CollisionProfileHandle &, const CollisionProfileHandle &)=default
Orders profile handles by id.
Runtime handle for a registered physics body component.
bool isValid() const
Checks whether this handle contains a body slot and generation.
friend bool operator==(const PhysicsBodyHandle &, const PhysicsBodyHandle &)=default
Compares body handles by id and generation.
std::uint32_t generation
Slot generation used to reject stale handles.
friend auto operator<=>(const PhysicsBodyHandle &, const PhysicsBodyHandle &)=default
Orders body handles by id and generation.
Collision profile filter used by PhysicsEngine scene queries.
bool includeOverlaps
Accept candidates that resolve to CollisionResponse::Overlap.
bool includeBlocks
Accept candidates that resolve to CollisionResponse::Block.
CollisionProfileHandle profile
Query profile tested against candidate body collision profiles.