PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
physics_world.h
1#pragma once
2
3#include "pixelbullet/physics/physics_types.h"
4
5#include <memory>
6#include <optional>
7#include <vector>
8
9namespace pixelbullet
10{
11struct PhysicsWorldImpl;
12
13class PhysicsWorld
14{
15public:
16 PhysicsWorld();
17 ~PhysicsWorld();
18
19 PhysicsWorld(const PhysicsWorld&) = delete;
20 PhysicsWorld& operator=(const PhysicsWorld&) = delete;
21
22 void Clear();
23 [[nodiscard]] PhysicsBodyHandle CreateBody(const PhysicsBodyCreateInfo& create_info);
24 void DestroyBody(PhysicsBodyHandle handle);
25
26 [[nodiscard]] bool IsBodyValid(PhysicsBodyHandle handle) const;
27 void SetBodyPose(PhysicsBodyHandle handle, const PhysicsBodyPose& pose, bool activate = true);
28 void MoveKinematicBody(PhysicsBodyHandle handle, const PhysicsBodyPose& pose, float delta_seconds);
29 [[nodiscard]] std::optional<PhysicsBodyPose> GetBodyPose(PhysicsBodyHandle handle) const;
30 [[nodiscard]] std::optional<PhysicsSweepHit> SweepCapsule(const PhysicsBodyPose& pose, float capsule_radius, float capsule_half_height,
31 glm::vec3 translation, PhysicsBodyHandle ignore_body = {},
32 PhysicsBodyHandle extra_ignore_body = {}) const;
33 [[nodiscard]] std::optional<PhysicsRayHit> CastRay(glm::vec3 origin, glm::vec3 translation, PhysicsBodyHandle ignore_body = {},
34 PhysicsBodyHandle extra_ignore_body = {}) const;
35 [[nodiscard]] std::optional<PhysicsSweepHit> ProbeCapsuleDown(const PhysicsBodyPose& pose, float capsule_radius,
36 float capsule_half_height, float probe_distance,
37 PhysicsBodyHandle ignore_body = {}) const;
38 [[nodiscard]] std::vector<PhysicsTriggerEvent> ConsumeTriggerEvents();
39
40 void Step(float delta_seconds);
41
42private:
43 std::unique_ptr<PhysicsWorldImpl> impl_;
44};
45} // namespace pixelbullet
Definition physics_types.h:76
Definition physics_types.h:25
Definition physics_types.h:37
Definition physics_world_internal.h:103