Skylicht Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
Collision
COctreeBuilder.h
1
/*
2
!@
3
MIT License
4
5
Copyright (c) 2021 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 "CCollisionBuilder.h"
28
29
namespace
Skylicht
30
{
31
class
COctreeBuilder :
public
CCollisionBuilder
32
{
33
protected
:
34
COctreeNode
* m_root;
35
36
u32
m_minimalPolysPerNode;
37
38
core::array<core::triangle3df*>
m_triangles;
39
core::array<CCollisionNode*>
m_collisions;
40
41
public
:
42
COctreeBuilder();
43
44
virtual
~COctreeBuilder();
45
46
virtual
void
build();
47
48
virtual
void
clear();
49
50
void
drawDebug();
51
52
public
:
53
54
virtual
bool
getCollisionPoint(
55
const
core::line3d<f32>
& ray,
56
f32
& outBestDistanceSquared,
57
core::vector3df
& outIntersection,
58
core::triangle3df
& outTriangle,
59
CCollisionNode
*& outNode);
60
61
virtual
void
getTriangles(
const
core::aabbox3df
& box,
62
core::array<core::triangle3df*>
& result,
63
core::array<CCollisionNode*>
& nodes);
64
65
protected
:
66
67
void
constructOctree(
COctreeNode
* node);
68
69
void
getTrianglesFromOctree(
70
core::array<core::triangle3df*>
& listTriangle,
71
core::array<CCollisionNode*>
& listCollisions,
72
COctreeNode
* node,
73
const
core::vector3df
& midLine,
74
const
core::vector3df
& lineVect,
75
float
halfLength);
76
77
void
getTrianglesFromOctree(
78
core::array<core::triangle3df*>
& listTriangle,
79
core::array<CCollisionNode*>
& listCollisions,
80
COctreeNode
* node,
81
const
core::aabbox3df
& box);
82
};
83
}
Skylicht::CCollisionNode
Definition
CCollisionNode.h:34
Skylicht::COctreeNode
Definition
COctreeNode.h:32
irr::core::array
Self reallocating template array (like stl vector) with additional features.
Definition
irrArray.h:23
irr::core::line3d
3D line between two points with intersection methods.
Definition
line3d.h:19
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::triangle3df
triangle3d< f32 > triangle3df
Typedef for a f32 3d triangle.
Definition
triangle3d.h:335
irr::core::aabbox3df
aabbox3d< f32 > aabbox3df
Typedef for a f32 3d bounding box.
Definition
aabbox3d.h:351
irr::f32
float f32
32 bit floating point variable.
Definition
irrTypes.h:104
irr::u32
unsigned int u32
32 bit unsigned variable.
Definition
irrTypes.h:58
Generated by
1.17.0