From 73ca83184894f7c6a24178b25095088c7b4c508c Mon Sep 17 00:00:00 2001 From: Anarchid Date: Wed, 20 Apr 2016 21:19:05 +0300 Subject: Implement GridMap support for navigation meshes --- modules/gridmap/grid_map.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'modules/gridmap/grid_map.h') diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index 66d3e6b44a..06dbabbc54 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -32,6 +32,7 @@ #include "scene/resources/mesh_library.h" #include "scene/3d/spatial.h" +#include "scene/3d/navigation.h" #include "scene/resources/multimesh.h" //heh heh, godotsphir!! this shares no code and the design is completely different with previous projects i've done.. @@ -46,7 +47,7 @@ class GridMap : public Spatial { OBJ_TYPE( GridMap, Spatial ); enum { - MAP_DIRTY_TRANSFORMS=1, + MAP_DIRTY_TRANSFORMS=1, MAP_DIRTY_INSTANCES=2, }; @@ -67,6 +68,9 @@ class GridMap : public Spatial { IndexKey() { key=0; } }; + /** + * @brief A Cell is a single cell in the cube map space; it is defined by its coordinates and the populating Item, identified by int id. + */ union Cell { struct { @@ -79,16 +83,24 @@ class GridMap : public Spatial { Cell() { item=0; rot=0; layer=0; } }; + /** + * @brief An Octant is a prism containing Cells, and possibly belonging to an Area. + * A GridMap can have multiple Octants. + */ struct Octant { - struct ItemInstances { + struct NavMesh { + int id; + Transform xform; + }; + struct ItemInstances { Set cells; Ref mesh; Ref shape; Ref multimesh; RID multimesh_instance; - + Ref navmesh; }; Ref baked; @@ -98,9 +110,8 @@ class GridMap : public Spatial { bool dirty; RID static_body; - Map items; - + Map navmesh_ids; }; union OctantKey { @@ -131,7 +142,7 @@ class GridMap : public Spatial { bool center_x,center_y,center_z; bool bake; float cell_scale; - + Navigation *navigation; bool clip; bool clip_above; @@ -140,7 +151,9 @@ class GridMap : public Spatial { Vector3::Axis clip_axis; - + /** + * @brief An Area is something like a room: it has doors, and Octants can choose to belong to it. + */ struct Area { String name; @@ -188,10 +201,12 @@ class GridMap : public Spatial { } void _octant_enter_world(const OctantKey &p_key); + void _octant_enter_tree(const OctantKey &p_key); void _octant_exit_world(const OctantKey &p_key); void _octant_update(const OctantKey &p_key); void _octant_transform(const OctantKey &p_key); void _octant_clear_baked(const OctantKey &p_key); + void _octant_clear_navmesh(const GridMap::OctantKey&); void _octant_bake(const OctantKey &p_key,const Ref& p_tmesh=RES(),const Vector &p_lights=Vector(),List *r_prebake=NULL); bool awaiting_update; -- cgit v1.2.3 From b03a892f9574d78da2cfded1b829c549dd1fced1 Mon Sep 17 00:00:00 2001 From: Anarchid Date: Wed, 20 Apr 2016 21:21:51 +0300 Subject: manually fix indent --- modules/gridmap/grid_map.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gridmap/grid_map.h') diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index 06dbabbc54..0116ea094f 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -47,7 +47,7 @@ class GridMap : public Spatial { OBJ_TYPE( GridMap, Spatial ); enum { - MAP_DIRTY_TRANSFORMS=1, + MAP_DIRTY_TRANSFORMS=1, MAP_DIRTY_INSTANCES=2, }; -- cgit v1.2.3