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
8namespace pixelbullet
9{
10struct PhysicsWorldImpl;
11
12class PhysicsWorld
13{
14public:
15 PhysicsWorld();
16 ~PhysicsWorld();
17
18 PhysicsWorld(const PhysicsWorld&) = delete;
19 PhysicsWorld& operator=(const PhysicsWorld&) = delete;
20
21 void Clear();
22 [[nodiscard]] PhysicsBodyHandle CreateBody(const PhysicsBodyCreateInfo& create_info);
23 void DestroyBody(PhysicsBodyHandle handle);
24
25 [[nodiscard]] bool IsBodyValid(PhysicsBodyHandle handle) const;
26 void SetBodyPose(PhysicsBodyHandle handle, const PhysicsBodyPose& pose, bool activate = true);
27 void MoveKinematicBody(PhysicsBodyHandle handle, const PhysicsBodyPose& pose, float delta_seconds);
28 [[nodiscard]] std::optional<PhysicsBodyPose> GetBodyPose(PhysicsBodyHandle handle) const;
29 [[nodiscard]] std::optional<PhysicsSweepHit> SweepCapsule(const PhysicsBodyPose& pose, float capsule_radius, float capsule_half_height,
30 glm::vec3 translation, PhysicsBodyHandle ignore_body = {},
31 PhysicsBodyHandle extra_ignore_body = {}) const;
32 [[nodiscard]] std::optional<PhysicsRayHit> CastRay(glm::vec3 origin, glm::vec3 translation, PhysicsBodyHandle ignore_body = {},
33 PhysicsBodyHandle extra_ignore_body = {}) const;
34 [[nodiscard]] std::optional<PhysicsSweepHit> ProbeCapsuleDown(const PhysicsBodyPose& pose, float capsule_radius,
35 float capsule_half_height, float probe_distance,
36 PhysicsBodyHandle ignore_body = {}) const;
37 [[nodiscard]] std::vector<PhysicsTriggerEvent> ConsumeTriggerEvents();
38
39 void Step(float delta_seconds);
40
41private:
42 std::unique_ptr<PhysicsWorldImpl> impl_;
43};
44} // namespace pixelbullet
Definition physics_types.h:77
Definition physics_types.h:27
Definition physics_types.h:39
Definition physics_world_internal.h:101