Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
pointedthing.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include "irrlichttypes.h"
8#include "irr_v3d.h"
9#include <iostream>
10#include <string>
11#include "pointabilities.h"
12
19
22{
52 u16 object_id = 0;
57 u16 box_id = 0;
80 f32 distanceSq = 0;
81
83 PointedThing() = default;
85 inline PointedThing(const v3s16 under, const v3s16 above,
86 const v3s16 real_under, const v3f point, const v3f normal,
87 u16 box_id, f32 distSq, PointabilityType pointab) :
89 pointability(pointab),
90 node_undersurface(under),
91 node_abovesurface(above),
92 node_real_undersurface(real_under),
94 intersection_point(point),
95 intersection_normal(normal),
96 distanceSq(distSq)
97 {}
99 inline PointedThing(u16 id, const v3f point, const v3f normal,
100 const v3f raw_normal, f32 distSq, PointabilityType pointab) :
102 pointability(pointab),
103 object_id(id),
104 intersection_point(point),
105 intersection_normal(normal),
106 raw_intersection_normal(raw_normal),
107 distanceSq(distSq)
108 {}
109
110 std::string dump() const;
111 void serialize(std::ostream &os) const;
112 void deSerialize(std::istream &is);
113
117 bool operator==(const PointedThing &pt2) const;
118 bool operator!=(const PointedThing &pt2) const {
119 return !(*this == pt2);
120 }
121};
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
core::vector3df v3f
Definition irr_v3d.h:11
PointabilityType
Definition pointabilities.h:13
PointedThingType
Definition pointedthing.h:14
@ POINTEDTHING_OBJECT
Definition pointedthing.h:17
@ POINTEDTHING_NODE
Definition pointedthing.h:16
@ POINTEDTHING_NOTHING
Definition pointedthing.h:15
An active object or node which is selected by a ray on the map.
Definition pointedthing.h:22
f32 distanceSq
Definition pointedthing.h:80
PointedThing(const v3s16 under, const v3s16 above, const v3s16 real_under, const v3f point, const v3f normal, u16 box_id, f32 distSq, PointabilityType pointab)
Constructor for POINTEDTHING_NODE.
Definition pointedthing.h:85
v3f intersection_normal
Definition pointedthing.h:70
std::string dump() const
Definition pointedthing.cpp:11
v3s16 node_abovesurface
Definition pointedthing.h:41
v3f raw_intersection_normal
Definition pointedthing.h:75
PointedThing()=default
Constructor for POINTEDTHING_NOTHING.
u16 box_id
Definition pointedthing.h:57
PointabilityType pointability
How the object or node can be pointed at.
Definition pointedthing.h:26
v3s16 node_undersurface
Definition pointedthing.h:34
bool operator!=(const PointedThing &pt2) const
Definition pointedthing.h:118
v3f intersection_point
Definition pointedthing.h:63
void deSerialize(std::istream &is)
Definition pointedthing.cpp:52
PointedThingType type
The type of the pointed object.
Definition pointedthing.h:24
void serialize(std::ostream &os) const
Definition pointedthing.cpp:35
bool operator==(const PointedThing &pt2) const
Definition pointedthing.cpp:73
v3s16 node_real_undersurface
Definition pointedthing.h:47
u16 object_id
Definition pointedthing.h:52
PointedThing(u16 id, const v3f point, const v3f normal, const v3f raw_normal, f32 distSq, PointabilityType pointab)
Constructor for POINTEDTHING_OBJECT.
Definition pointedthing.h:99