Kemena3D
Loading...
Searching...
No Matches
kphysicsmanager.h
Go to the documentation of this file.
1
5
6#ifndef KPHYSICSMANAGER_H
7#define KPHYSICSMANAGER_H
8
9#include "kexport.h"
10#include "kdatatype.h"
11#include "kphysicsobject.h"
13
14namespace kemena
15{
23 {
24 bool hit = false;
25 float distance = 0.0f;
28 kPhysicsObject *object = nullptr;
29 };
30
57 {
58 public:
61
64
65 // --- Lifecycle -------------------------------------------------------
66
71 bool init();
72
77 void shutdown();
78
79 // --- Simulation ------------------------------------------------------
80
86 void update(float deltaTime);
87
88 // --- World settings --------------------------------------------------
89
94 void setGravity(const kVec3 &gravity);
95
98
99 // --- Object factory --------------------------------------------------
100
111
117
129
135
136 // --- Queries ---------------------------------------------------------
137
160 const kVec3 &direction,
161 float maxDistance = 1000.0f);
162
163 protected:
164 private:
165 struct Impl;
166 Impl *m_impl;
167 };
168
169} // namespace kemena
170
171#endif // KPHYSICSMANAGER_H
Runtime wrapper around a Jolt character.
Definition kcharactercontroller.h:47
kVec3 getGravity() const
Returns the current global gravity vector (m/s²).
kPhysicsManager()
Constructs an uninitialised manager; call init() before use.
bool init()
Initialises the Jolt physics engine and internal systems.
kPhysicsRaycastHit raycast(const kVec3 &origin, const kVec3 &direction, float maxDistance=1000.0f)
Casts a ray into the physics world and returns the closest hit.
void destroyObject(kPhysicsObject *object)
Removes a physics body from the simulation and destroys the object.
void destroyCharacter(kCharacterController *character)
Removes a character controller from the simulation and destroys it.
void update(float deltaTime)
Advances the simulation by deltaTime seconds.
void setGravity(const kVec3 &gravity)
Sets the global gravity vector (m/s²).
void shutdown()
Destroys all physics bodies and tears down the engine. Called automatically by the destructor.
kCharacterController * createCharacter(const kCharacterControllerDesc &desc)
Creates a character controller in this physics world.
~kPhysicsManager()
Destroys the manager, calling shutdown() to release all bodies.
kPhysicsObject * createObject(const kPhysicsObjectDesc &desc)
Creates a physics body and returns a new kPhysicsObject.
Represents a single rigid body or trigger volume inside the physics simulation.
Definition kphysicsobject.h:131
Capsule character controller built on Jolt's JPH::Character.
Core type aliases, enumerations, structs, and utility functions used throughout the engine.
Symbol visibility / linkage macro for the Kemena3D library.
#define KEMENA3D_API
Definition kexport.h:35
A single physics body — shape, type (dynamic / static / kinematic / trigger), and runtime controls.
Top-level Kemena3D engine namespace.
Definition kanimation.h:23
glm::vec3 kVec3
3-component float vector.
Definition kdatatype.h:33
Editor-authored description of a character controller.
Definition kcharactercontroller.h:26
All parameters needed to create a kPhysicsObject.
Definition kphysicsobject.h:92
Result of a physics raycast query.
Definition kphysicsmanager.h:23
float distance
Distance from the ray origin to the hit point.
Definition kphysicsmanager.h:25
kVec3 hitNormal
World-space surface normal at the hit point.
Definition kphysicsmanager.h:27
bool hit
true if the ray struck a body.
Definition kphysicsmanager.h:24
kVec3 hitPoint
World-space position of the intersection.
Definition kphysicsmanager.h:26