Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
VisualSensor.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_AI_VISUAL_SENSOR_H_
34#define DVD_AI_VISUAL_SENSOR_H_
35
36#include "Sensor.h"
37
38namespace Divide {
39
40FWD_DECLARE_MANAGED_CLASS(SceneGraphNode);
41
42namespace AI {
43
52
53class VisualSensor final : public Sensor
54{
55 public:
56 explicit VisualSensor(AIEntity* parentEntity);
57 ~VisualSensor() override;
58
59 void update(U64 deltaTimeUS) override;
60
61 void followSceneGraphNode(U32 containerID, SceneGraphNode* node);
62 void unfollowSceneGraphNode(U32 containerID, I64 nodeGUID);
63
64 F32 getDistanceToNodeSq(U32 containerID, I64 nodeGUID);
65
66 F32 getDistanceToNode(const U32 containerID, const I64 nodeGUID) {
67 const F32 distanceSq = getDistanceToNodeSq(containerID, nodeGUID);
68 if (distanceSq < F32_MAX - 1.f) {
69 return Sqrt(distanceSq);
70 }
71 return distanceSq;
72 }
73
74 vec3<F32> getNodePosition(U32 containerID, I64 nodeGUID);
76
77
78 protected:
81};
82
83} // namespace AI
84} // namespace Divide
85
86#endif //DVD_AI_VISUAL_SENSOR_H_
#define FWD_DECLARE_MANAGED_CLASS(T)
Based on OgreCrowd.
Definition: AIEntity.h:60
NodePositionsMap _nodePositionsMap
Definition: VisualSensor.h:80
F32 getDistanceToNode(const U32 containerID, const I64 nodeGUID)
Definition: VisualSensor.h:66
SceneGraphNode * findClosestNode(U32 containerID)
vec3< F32 > getNodePosition(U32 containerID, I64 nodeGUID)
F32 getDistanceToNodeSq(U32 containerID, I64 nodeGUID)
NodeContainerMap _nodeContainerMap
Definition: VisualSensor.h:79
void unfollowSceneGraphNode(U32 containerID, I64 nodeGUID)
void followSceneGraphNode(U32 containerID, SceneGraphNode *node)
void update(U64 deltaTimeUS) override
hashMap< U32, NodeContainer > NodeContainerMap
Container ID, NodeContainer.
Definition: VisualSensor.h:47
hashMap< I64, vec3< F32 > > NodePositions
SGN GUID, Last position.
Definition: VisualSensor.h:49
hashMap< U32, NodePositions > NodePositionsMap
Container ID, NodePositions.
Definition: VisualSensor.h:51
hashMap< I64, SceneGraphNode * > NodeContainer
SGN GUID, SGN pointer.
Definition: VisualSensor.h:45
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
T Sqrt(T input) noexcept
Definition: MathHelper.inl:252
hashAlg::unordered_map< K, V, HashFun, Predicate > hashMap
Definition: HashMap.h:55
constexpr F32 F32_MAX
int64_t I64
uint32_t U32
uint64_t U64