This commit is contained in:
Your Name 2024-06-08 15:03:04 +02:00
parent 7cafc09390
commit 25056fd5e8
5 changed files with 12 additions and 39 deletions

View file

@ -17,3 +17,4 @@ src/RecastNavMesh.cpp
target_include_directories(godot-recast-navigation PRIVATE src/)
target_link_libraries(godot-recast-navigation PUBLIC godot::cpp Recast)
target_link_options(godot-recast-navigation PRIVATE -Wl,--no-undefined)

View file

@ -1,17 +0,0 @@
#include "RecastContext.hpp"
godot::RecastContext::RecastContext() {
}
godot::RecastContext::~RecastContext() {
}
void godot::RecastContext::_bind_methods() {
ADD_SIGNAL(MethodInfo("do_log"), PropertyInfo(Variant::INT, "category"), PropertyInfo(Variant::STRING, "msg"));
}
void godot::RecastContext::doLog(const rcLogCategory category, const char* msg, const int len) {
}

View file

@ -1,19 +0,0 @@
#pragma once
#include "godot_cpp/classes/node3d.hpp"
#include "Recast.h"
namespace godot {
class RecastContext : public Object, public rcContext {
GDCLASS(RecastContext, Object)
private:
protected:
static void _bind_methods();
virtual void doLog(const rcLogCategory category, const char* msg, const int len);
public:
RecastContext();
~RecastContext();
};
}

View file

@ -1,7 +1,9 @@
#include "RecastNavMesh.hpp"
#include "Recast.h"
#include <godot_cpp/classes/global_constants.hpp>
#include <godot_cpp/core/object.hpp>
godot::RecastNavMesh::RecastNavMesh() {
godot::RecastNavMesh::RecastNavMesh() : Node3D(), rcContext() {
}
godot::RecastNavMesh::~RecastNavMesh() {
@ -9,6 +11,8 @@ godot::RecastNavMesh::~RecastNavMesh() {
}
void godot::RecastNavMesh::_bind_methods() {
// Context
ADD_SIGNAL(MethodInfo("do_log", PropertyInfo(Variant::INT, "category"), PropertyInfo(Variant::STRING, "msg")));
// Config
ClassDB::bind_method(D_METHOD("get_width"), &RecastNavMesh::get_width);
ClassDB::bind_method(D_METHOD("get_height"), &RecastNavMesh::get_height);

View file

@ -1,7 +1,6 @@
#pragma once
#include "godot_cpp/classes/node3d.hpp"
#include "godot_cpp/templates/vector.hpp"
#include "Recast.h"
@ -14,7 +13,7 @@ enum RecastPartitionType {
PARTITION_TYPE_COUNT
};
class RecastNavMesh : public Node3D {
class RecastNavMesh : public Node3D, public rcContext {
GDCLASS(RecastNavMesh, Node3D)
private:
bool m_calculated = false;
@ -27,8 +26,13 @@ private:
rcHeightfield* m_heightfield = NULL;
rcCompactHeightfield* m_compact_heightfield = NULL;
rcPolyMesh* m_poly_mesh = NULL;
rcPolyMeshDetail* m_poly_mesh_detail = NULL;
protected:
static void _bind_methods();
void doLog(const rcLogCategory category, const char* msg, const int len) override {
emit_signal("do_log", category, msg);
}
public:
RecastNavMesh();
~RecastNavMesh();