diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-03-05 16:44:50 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2017-03-05 16:44:50 +0100 |
commit | 5dbf1809c6e3e905b94b8764e99491e608122261 (patch) | |
tree | 5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /modules/gridmap/grid_map.h | |
parent | 45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff) | |
download | redot-engine-5dbf1809c6e3e905b94b8764e99491e608122261.tar.gz |
A Whole New World (clang-format edition)
I can show you the code
Pretty, with proper whitespace
Tell me, coder, now when did
You last write readable code?
I can open your eyes
Make you see your bad indent
Force you to respect the style
The core devs agreed upon
A whole new world
A new fantastic code format
A de facto standard
With some sugar
Enforced with clang-format
A whole new world
A dazzling style we all dreamed of
And when we read it through
It's crystal clear
That now we're in a whole new world of code
Diffstat (limited to 'modules/gridmap/grid_map.h')
-rw-r--r-- | modules/gridmap/grid_map.h | 88 |
1 files changed, 39 insertions, 49 deletions
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index 5d4133383b..2a0c2b9646 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -29,26 +29,23 @@ #ifndef GRID_MAP_H #define GRID_MAP_H - -#include "scene/resources/mesh_library.h" -#include "scene/3d/spatial.h" #include "scene/3d/navigation.h" +#include "scene/3d/spatial.h" +#include "scene/resources/mesh_library.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.. //should scale better with hardware that supports instancing - class BakedLightInstance; class GridMap : public Spatial { - - GDCLASS( GridMap, Spatial ); + GDCLASS(GridMap, Spatial); enum { - MAP_DIRTY_TRANSFORMS=1, - MAP_DIRTY_INSTANCES=2, + MAP_DIRTY_TRANSFORMS = 1, + MAP_DIRTY_INSTANCES = 2, }; union IndexKey { @@ -60,12 +57,12 @@ class GridMap : public Spatial { }; uint64_t key; - _FORCE_INLINE_ bool operator<(const IndexKey& p_key) const { + _FORCE_INLINE_ bool operator<(const IndexKey &p_key) const { return key < p_key.key; } - IndexKey() { key=0; } + IndexKey() { key = 0; } }; /** @@ -75,12 +72,16 @@ class GridMap : public Spatial { struct { unsigned int item : 16; - unsigned int rot:5; - unsigned int layer:8; + unsigned int rot : 5; + unsigned int layer : 8; }; uint32_t cell; - Cell() { item=0; rot=0; layer=0; } + Cell() { + item = 0; + rot = 0; + layer = 0; + } }; /** @@ -108,8 +109,8 @@ class GridMap : public Spatial { bool dirty; RID static_body; - Map<int,ItemInstances> items; - Map<IndexKey,NavMesh> navmesh_ids; + Map<int, ItemInstances> items; + Map<IndexKey, NavMesh> navmesh_ids; }; union OctantKey { @@ -123,13 +124,13 @@ class GridMap : public Spatial { uint64_t key; - _FORCE_INLINE_ bool operator<(const OctantKey& p_key) const { + _FORCE_INLINE_ bool operator<(const OctantKey &p_key) const { return key < p_key.key; } //OctantKey(const IndexKey& p_k, int p_item) { indexkey=p_k.key; item=p_item; } - OctantKey() { key=0; } + OctantKey() { key = 0; } }; Transform last_transform; @@ -137,7 +138,7 @@ class GridMap : public Spatial { bool _in_tree; float cell_size; int octant_size; - bool center_x,center_y,center_z; + bool center_x, center_y, center_z; float cell_scale; Navigation *navigation; @@ -146,7 +147,6 @@ class GridMap : public Spatial { int clip_floor; Vector3::Axis clip_axis; - /** * @brief An Area is something like a room: it has doors, and Octants can choose to belong to it. */ @@ -173,11 +173,9 @@ class GridMap : public Spatial { Ref<MeshLibrary> theme; - Map<OctantKey,Octant*> octant_map; - Map<IndexKey,Cell> cell_map; - Map<int,Area*> area_map; - - + Map<OctantKey, Octant *> octant_map; + Map<IndexKey, Cell> cell_map; + Map<int, Area *> area_map; void _recreate_octant_data(); @@ -189,11 +187,11 @@ class GridMap : public Spatial { float param[VS::LIGHT_PARAM_MAX]; }; - _FORCE_INLINE_ int _find_area(const IndexKey& p_pos) const; + _FORCE_INLINE_ int _find_area(const IndexKey &p_pos) const; _FORCE_INLINE_ Vector3 _octant_get_offset(const OctantKey &p_key) const { - return Vector3(p_key.x,p_key.y,p_key.z)*cell_size*octant_size; + return Vector3(p_key.x, p_key.y, p_key.z) * cell_size * octant_size; } void _octant_enter_world(const OctantKey &p_key); @@ -201,37 +199,33 @@ class GridMap : public Spatial { 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_navmesh(const GridMap::OctantKey&); + void _octant_clear_navmesh(const GridMap::OctantKey &); bool awaiting_update; void _queue_dirty_map(); void _update_dirty_map_callback(); - void resource_changed(const RES& p_res); - + void resource_changed(const RES &p_res); void _update_areas(); void _update_area_instances(); - void _clear_internal(bool p_keep_areas=false); + void _clear_internal(bool p_keep_areas = false); protected: - - bool _set(const StringName& p_name, const Variant& p_value); - bool _get(const StringName& p_name,Variant &r_ret) const; - void _get_property_list( List<PropertyInfo> *p_list) const; + bool _set(const StringName &p_name, const Variant &p_value); + bool _get(const StringName &p_name, Variant &r_ret) const; + void _get_property_list(List<PropertyInfo> *p_list) const; void _notification(int p_what); static void _bind_methods(); - public: - enum { - INVALID_CELL_ITEM=-1 + INVALID_CELL_ITEM = -1 }; - void set_theme(const Ref<MeshLibrary>& p_theme); + void set_theme(const Ref<MeshLibrary> &p_theme); Ref<MeshLibrary> get_theme() const; void set_cell_size(float p_size); @@ -240,7 +234,6 @@ public: void set_octant_size(int p_size); int get_octant_size() const; - void set_center_x(bool p_enable); bool get_center_x() const; void set_center_y(bool p_enable); @@ -248,16 +241,16 @@ public: void set_center_z(bool p_enable); bool get_center_z() const; - void set_cell_item(int p_x,int p_y,int p_z, int p_item,int p_orientation=0); - int get_cell_item(int p_x,int p_y,int p_z) const; - int get_cell_item_orientation(int p_x,int p_y,int p_z) const; + void set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_orientation = 0); + int get_cell_item(int p_x, int p_y, int p_z) const; + int get_cell_item_orientation(int p_x, int p_y, int p_z) const; - void set_clip(bool p_enabled, bool p_clip_above=true, int p_floor=0, Vector3::Axis p_axis=Vector3::AXIS_X); + void set_clip(bool p_enabled, bool p_clip_above = true, int p_floor = 0, Vector3::Axis p_axis = Vector3::AXIS_X); - Error create_area(int p_id,const Rect3& p_area); + Error create_area(int p_id, const Rect3 &p_area); Rect3 area_get_bounds(int p_area) const; - void area_set_exterior_portal(int p_area,bool p_enable); - void area_set_name(int p_area,const String& p_name); + void area_set_exterior_portal(int p_area, bool p_enable); + void area_set_name(int p_area, const String &p_name); String area_get_name(int p_area) const; bool area_is_exterior_portal(int p_area) const; void area_set_portal_disable_distance(int p_area, float p_distance); @@ -271,11 +264,8 @@ public: void set_cell_scale(float p_scale); float get_cell_scale() const; - - Array get_meshes(); - void clear(); GridMap(); |