Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
PXDevice.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_PHYSICS_DEVICE_H_
34#define DVD_PHYSICS_DEVICE_H_
35
39
40namespace Divide {
41
42class PhysicsAsset;
43class PXDevice final : public PhysicsAPIWrapper, public FrameListener
44{
45public:
46 enum class PhysicsAPI : U8 {
47 PhysX = 0,
48 ODE,
49 Bullet,
50 COUNT
51 };
52
53 explicit PXDevice( PlatformContext& context ) noexcept;
54 ~PXDevice() override;
55
56 ErrorCode initPhysicsAPI(U8 targetFrameRate, F32 simSpeed) override;
57 bool closePhysicsAPI() override;
58
59 void updateTimeStep(U8 timeStepFactor, F32 simSpeed) override;
60 void idle() override;
61 bool convertActor(PhysicsAsset* actor, PhysicsGroup newGroup) override;
62
63 bool initPhysicsScene(Scene& scene) override;
64 bool destroyPhysicsScene(const Scene& scene) override;
65
67
68 [[nodiscard]] PhysicsAPIWrapper& getImpl() { assert(_api != nullptr); return *_api; }
69 [[nodiscard]] const PhysicsAPIWrapper& getImpl() const { assert(_api != nullptr); return *_api; }
70
71 bool intersect(const Ray& intersectionRay, vec2<F32> range, vector<SGNRayResult>& intersectionsOut) const override;
72
73 [[nodiscard]] bool frameStarted( const FrameEvent& evt ) override;
74 [[nodiscard]] bool frameEnded( const FrameEvent& evt ) noexcept override;
75
77
78protected:
79 void frameStarted( U64 deltaTimeGameUS ) override;
80 void frameEnded( U64 deltaTimeGameUS ) noexcept override;
81
82private:
84 PhysicsAPIWrapper_uptr _api = nullptr;
85
86};
87
88}; // namespace Divide
89
90#endif //DVD_PHYSICS_DEVICE_H_
void updateTimeStep(U8 timeStepFactor, F32 simSpeed) override
Definition: PXDevice.cpp:69
ErrorCode initPhysicsAPI(U8 targetFrameRate, F32 simSpeed) override
Definition: PXDevice.cpp:33
const PhysicsAPIWrapper & getImpl() const
Definition: PXDevice.h:69
bool initPhysicsScene(Scene &scene) override
Definition: PXDevice.cpp:108
PhysicsAPIWrapper_uptr _api
Definition: PXDevice.h:84
bool destroyPhysicsScene(const Scene &scene) override
Definition: PXDevice.cpp:113
PhysicsAPIWrapper & getImpl()
Definition: PXDevice.h:68
bool intersect(const Ray &intersectionRay, vec2< F32 > range, vector< SGNRayResult > &intersectionsOut) const override
Definition: PXDevice.cpp:130
bool frameStarted(const FrameEvent &evt) override
Definition: PXDevice.cpp:88
F32 _simulationSpeed
Definition: PXDevice.h:83
bool closePhysicsAPI() override
Definition: PXDevice.cpp:55
~PXDevice() override
Definition: PXDevice.cpp:28
void idle() override
Definition: PXDevice.cpp:101
PhysicsAsset * createRigidActor(SceneGraphNode *node, RigidBodyComponent &parentComp) override
Definition: PXDevice.cpp:118
bool convertActor(PhysicsAsset *actor, PhysicsGroup newGroup) override
Definition: PXDevice.cpp:124
PROPERTY_RW(PhysicsAPI, apiID, PhysicsAPI::COUNT)
bool frameEnded(const FrameEvent &evt) noexcept override
frameEnded is called after the buffers have been swapped
Definition: PXDevice.cpp:75
PlatformContext & context() noexcept
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
uint8_t U8
eastl::vector< Type > vector
Definition: Vector.h:42
uint64_t U64