Rigs of Rods 2023.09
Soft-body Physics Simulation
Loading...
Searching...
No Matches
PointColDetector.h
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2009 Lefteris Stamatogiannakis
4
5 For more information, see http://www.rigsofrods.org/
6
7 Rigs of Rods is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 3, as
9 published by the Free Software Foundation.
10
11 Rigs of Rods is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include "Application.h"
23
24namespace RoR {
25
28
31
33{
34public:
35
36 struct pointid_t // use PointidID_t for indexing
37 {
40 };
41
42 std::vector<PointidID_t> hit_list;
43 std::unordered_set<ActorInstanceID_t> hit_list_actorset;
44 std::vector<pointid_t> hit_pointid_list;
45
47
48 void UpdateIntraPoint(bool contactables = false);
49 void UpdateInterPoint(bool ignorestate = false);
50 void query(const Ogre::Vector3& vec1, const Ogre::Vector3& vec2, const Ogre::Vector3& vec3, const float enlargeBB);
51
52private:
53
54 struct refelem_t // use RefelemID_t for indexing
55 {
57 std::array<float, 3> point; // cached node AbsPosition
58 void setPoint(const Ogre::Vector3 pos) { point[0] = pos.x; point[1] = pos.y; point[2] = pos.z; }
59 };
60
61 struct kdnode_t
62 {
63 float min;
64 int end;
65 float max;
67 float middle;
68 int begin;
69 };
70
72 std::vector<ActorInstanceID_t> m_collision_partners;
73 std::vector<refelem_t> m_ref_list;
74
75 std::vector<kdnode_t> m_kdtree;
76 Ogre::Vector3 m_bbmin = Ogre::Vector3::ZERO;
77 Ogre::Vector3 m_bbmax = Ogre::Vector3::ZERO;
79
80 void queryrec(int kdindex, int axis);
81 void build_kdtree_incr(int axis, int index);
82 void partintwo(const int start, const int median, const int end, const int axis, float& minex, float& maxex);
83 void update_structures_for_contacters(bool ignoreinternal);
85};
86
89
90} // namespace RoR
Central state/object manager and communications hub.
void update_structures_for_contacters(bool ignoreinternal)
std::vector< kdnode_t > m_kdtree
std::vector< refelem_t > m_ref_list
void partintwo(const int start, const int median, const int end, const int axis, float &minex, float &maxex)
void queryrec(int kdindex, int axis)
void query(const Ogre::Vector3 &vec1, const Ogre::Vector3 &vec2, const Ogre::Vector3 &vec3, const float enlargeBB)
PointColDetector(ActorPtr actor)
void UpdateIntraPoint(bool contactables=false)
std::vector< PointidID_t > hit_list
std::vector< ActorInstanceID_t > m_collision_partners
IntraPoint: always just owning actor; InterPoint: all colliding actors.
std::vector< pointid_t > hit_pointid_list
std::unordered_set< ActorInstanceID_t > hit_list_actorset
void UpdateInterPoint(bool ignorestate=false)
void build_kdtree_incr(int axis, int index)
static const NodeNum_t NODENUM_INVALID
static const PointidID_t POINTIDID_INVALID
int ActorInstanceID_t
Unique sequentially generated ID of an actor in session. Use ActorManager::GetActorById()
int RefelemID_t
index to PointColDetector::m_ref_list, use RoR::REFELEMID_INVALID as empty value.
static const ActorInstanceID_t ACTORINSTANCEID_INVALID
uint16_t NodeNum_t
Node position within Actor::ar_nodes; use RoR::NODENUM_INVALID as empty value.
int PointidID_t
index to PointColDetector::hit_pointid_list, use RoR::POINTIDID_INVALID as empty value.
static const RefelemID_t REFELEMID_INVALID
void setPoint(const Ogre::Vector3 pos)