Skylicht Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
Collider
CCollider.h
1
/*
2
!@
3
MIT License
4
5
Copyright (c) 2024 Skylicht Technology CO., LTD
6
7
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10
subject to the following conditions:
11
12
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20
This file is part of the "Skylicht Engine".
21
https://github.com/skylicht-lab/skylicht-engine
22
!#
23
*/
24
25
#pragma once
26
27
#include "Components/CComponentSystem.h"
28
29
#ifdef USE_BULLET_PHYSIC_ENGINE
30
#include <btBulletCollisionCommon.h>
31
#endif
32
33
#include "RenderMesh/CMesh.h"
34
35
namespace
Skylicht
36
{
37
namespace
Physics
38
{
46
class
CCollider :
public
CComponentSystem
47
{
48
public
:
53
enum
EColliderType
54
{ Box,
55
Sphere,
56
Plane,
57
Cylinder,
58
Capsule,
59
BvhMesh,
60
ConvexMesh,
61
Mesh,
62
Unknown,
63
};
64
65
protected
:
66
EColliderType
m_colliderType;
67
68
core::vector3df
m_offset;
69
70
bool
m_dynamicSupport;
71
72
#ifdef USE_BULLET_PHYSIC_ENGINE
73
btCollisionShape* m_shape;
74
#endif
75
76
public
:
77
CCollider
();
78
79
virtual
~CCollider
();
80
81
virtual
void
initComponent();
82
87
EColliderType
getColliderType
()
88
{
89
return
m_colliderType;
90
}
91
92
#ifdef USE_BULLET_PHYSIC_ENGINE
97
virtual
btCollisionShape* initCollisionShape() = 0;
98
102
virtual
void
dropCollisionShape();
103
#endif
104
108
void
initRigidbody
();
109
114
void
clampSize
(
core::vector3df
& size);
115
120
inline
bool
isDynamicSupport
()
121
{
122
return
m_dynamicSupport;
123
}
124
130
CMesh
*
generateMesh
(
const
core::aabbox3df
& maxBBox);
131
136
core::aabbox3df
getBBox
();
137
138
protected
:
139
143
CMesh
*
generateMesh
(IMesh* primitive,
bool
tangent);
144
148
CMesh
*
getPlane
(
const
core::plane3df
& plane,
float
sizeX,
float
sizeZ);
149
150
};
151
}
152
}
Skylicht::CMesh
Definition
CMesh.h:75
Skylicht::Physics::CCollider
Base class for all collision shapes.
Definition
CCollider.h:47
Skylicht::Physics::CCollider::getColliderType
EColliderType getColliderType()
Gets the type of the collider.
Definition
CCollider.h:87
Skylicht::Physics::CCollider::isDynamicSupport
bool isDynamicSupport()
Checks if this collider type supports dynamic rigid bodies.
Definition
CCollider.h:120
Skylicht::Physics::CCollider::generateMesh
CMesh * generateMesh(const core::aabbox3df &maxBBox)
Generates a visual mesh representing the collision shape.
Skylicht::Physics::CCollider::getPlane
CMesh * getPlane(const core::plane3df &plane, float sizeX, float sizeZ)
Helper to generate a plane mesh.
Skylicht::Physics::CCollider::initRigidbody
void initRigidbody()
Triggers the initialization of the attached CRigidbody.
Skylicht::Physics::CCollider::generateMesh
CMesh * generateMesh(IMesh *primitive, bool tangent)
Helper to generate a mesh from a primitive.
Skylicht::Physics::CCollider::getBBox
core::aabbox3df getBBox()
Gets the axis-aligned bounding box of the collider in world space.
Skylicht::Physics::CCollider::clampSize
void clampSize(core::vector3df &size)
Clamps the size vector to ensure no negative dimensions.
Skylicht::Physics::CCollider::EColliderType
EColliderType
Supported collider types.
Definition
CCollider.h:54
Skylicht
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition
AudioDebugLog.h:29
irr::core::vector3df
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition
vector3d.h:445
irr::core::aabbox3df
aabbox3d< f32 > aabbox3df
Typedef for a f32 3d bounding box.
Definition
aabbox3d.h:351
irr::core::plane3df
plane3d< f32 > plane3df
Typedef for a f32 3d plane.
Definition
plane3d.h:236
Generated by
1.17.0