34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
#include "clue_marker.h"
|
|
#include "macros.h"
|
|
#include "you_done_it/clue_finder.h"
|
|
#include "you_done_it/ydi_networking.h"
|
|
|
|
void ClueMarker::_bind_methods() {
|
|
BIND_HPROPERTY(Variant::INT, clue_id, PROPERTY_HINT_ENUM, NetworkData::ClueID_hint());
|
|
}
|
|
|
|
bool ClueMarker::is_visible() const {
|
|
Transform3D const viewpoint{ ClueFinder::get_singleton()->get_global_transform() };
|
|
Basis const basis{ viewpoint.get_basis() };
|
|
Vector3 const pos_relative{ get_global_position() - viewpoint.get_origin() };
|
|
Vector3 const pos_transformed{ basis.get_column(0).dot(pos_relative), basis.get_column(1).dot(pos_relative), basis.get_column(2).dot(pos_relative) };
|
|
if (pos_transformed.z <= 0.5f) {
|
|
return false;
|
|
}
|
|
Vector3 const transformed_dir{ pos_transformed.normalized() };
|
|
if (Math::abs(transformed_dir.signed_angle_to({ 0, 0, 1 }, { 0, 1, 0 })) > Math::PI / 4.0) {
|
|
return false;
|
|
}
|
|
if (Math::abs(transformed_dir.signed_angle_to({ 0, 0, 1 }, { 1, 0, 0 })) > Math::PI / 4.0) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void ClueMarker::set_clue_id(NetworkData::ClueID id) {
|
|
this->id = id;
|
|
}
|
|
|
|
NetworkData::ClueID ClueMarker::get_clue_id() const {
|
|
return this->id;
|
|
}
|