Skylicht Engine
Loading...
Searching...
No Matches
COctreeBuilder.h
1/*
2!@
3MIT License
4
5Copyright (c) 2021 Skylicht Technology CO., LTD
6
7Permission 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,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#pragma once
26
27#include "CCollisionBuilder.h"
28
29namespace Skylicht
30{
31 class COctreeBuilder : public CCollisionBuilder
32 {
33 protected:
34 COctreeNode* m_root;
35
36 u32 m_minimalPolysPerNode;
37
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,
64
65 protected:
66
67 void constructOctree(COctreeNode* node);
68
69 void getTrianglesFromOctree(
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(
79 core::array<CCollisionNode*>& listCollisions,
80 COctreeNode* node,
81 const core::aabbox3df& box);
82 };
83}
Definition CCollisionNode.h:34
Definition COctreeNode.h:32
Self reallocating template array (like stl vector) with additional features.
Definition irrArray.h:23
3D line between two points with intersection methods.
Definition line3d.h:19
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
triangle3d< f32 > triangle3df
Typedef for a f32 3d triangle.
Definition triangle3d.h:335
aabbox3d< f32 > aabbox3df
Typedef for a f32 3d bounding box.
Definition aabbox3d.h:351
float f32
32 bit floating point variable.
Definition irrTypes.h:104
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58