33 lines
1.1 KiB
C++
33 lines
1.1 KiB
C++
#include "nav_marker.hpp"
|
|
#include "utils/godot_macros.hpp"
|
|
#include <godot_cpp/classes/editor_interface.hpp>
|
|
#include <godot_cpp/classes/editor_selection.hpp>
|
|
#include <godot_cpp/classes/engine.hpp>
|
|
#include <godot_cpp/classes/navigation_server3d.hpp>
|
|
#include <godot_cpp/classes/world3d.hpp>
|
|
#include <godot_cpp/variant/rid.hpp>
|
|
|
|
void NavMarker::_bind_methods() {
|
|
#define CLASSNAME NavMarker
|
|
GDPROPERTY_HINTED(marker_type, gd::Variant::INT, gd::PROPERTY_HINT_ENUM, MarkerType::get_property_hint());
|
|
}
|
|
|
|
void NavMarker::_process(double) {
|
|
#ifdef DEBUG_ENABLED
|
|
// only run in editor while selected
|
|
if(gd::Engine::get_singleton()->is_editor_hint() && gd::EditorInterface::get_singleton()->get_selection()->get_selected_nodes().has(this)) {
|
|
gd::RID const map_id{this->get_world_3d()->get_navigation_map()};
|
|
gd::Vector3 const new_point{gd::NavigationServer3D::get_singleton()->map_get_closest_point(map_id, this->get_global_position())};
|
|
this->set_global_position(new_point);
|
|
}
|
|
#endif // DEBUG_ENABLED
|
|
}
|
|
|
|
void NavMarker::set_marker_type(int type) {
|
|
this->type = type;
|
|
}
|
|
|
|
int NavMarker::get_marker_type() const {
|
|
return this->type;
|
|
}
|