godot/scene/resources/tile_set.h
Rémi Verschelde 2091f20443 Fix warnings about wrong member initialization order [-Wreorder]
Fixes the following GCC 5 warnings:
```
core/object.h:193:11: warning: 'MethodInfo::flags' will be initialized after [-Wreorder]
core/object.h:192:15: warning:   'PropertyInfo MethodInfo::return_val' [-Wreorder]
core/object.cpp:278:1: warning:   when initialized here [-Wreorder]
core/script_debugger_remote.h:97:6: warning: 'ScriptDebuggerRemote::max_cps' will be initialized after [-Wreorder]
core/script_debugger_remote.h:91:6: warning:   'int ScriptDebuggerRemote::max_messages_per_frame' [-Wreorder]
core/script_debugger_remote.cpp:1086:1: warning:   when initialized here [-Wreorder]
core/script_debugger_remote.h:98:6: warning: 'ScriptDebuggerRemote::char_count' will be initialized after [-Wreorder]
core/script_debugger_remote.h:92:6: warning:   'int ScriptDebuggerRemote::n_messages_dropped' [-Wreorder]
core/script_debugger_remote.cpp:1086:1: warning:   when initialized here [-Wreorder]
modules/bullet/area_bullet.h:102:7: warning: 'AreaBullet::isScratched' will be initialized after [-Wreorder]
modules/bullet/area_bullet.h:92:39: warning:   'PhysicsServer::AreaSpaceOverrideMode AreaBullet::spOv_mode' [-Wreorder]
modules/bullet/area_bullet.cpp:46:1: warning:   when initialized here [-Wreorder]
modules/bullet/collision_object_bullet.h:127:15: warning: 'CollisionObjectBullet::space' will be initialized after [-Wreorder]
modules/bullet/collision_object_bullet.h:117:7: warning:   'CollisionObjectBullet::Type CollisionObjectBullet::type' [-Wreorder]
modules/bullet/collision_object_bullet.cpp:67:1: warning:   when initialized here [-Wreorder]
modules/bullet/godot_ray_world_algorithm.h:48:7: warning: 'GodotRayWorldAlgorithm::m_ownManifol1d' will be initialized after [-Wreorder]
modules/bullet/godot_ray_world_algorithm.h:46:33: warning:   'const btDiscreteDynamicsWorld* GodotRayWorldAlgorithm::m_world' [-Wreorder]
modules/bullet/godot_ray_world_algorithm.cpp:50:1: warning:   when initialized here [-Wreorder]
modules/bullet/godot_result_callbacks.h:91:18: warning: 'GodotAllConvexResultCallback::m_exclude' will be initialized after [-Wreorder]
modules/bullet/godot_result_callbacks.h:89:6: warning:   'int GodotAllConvexResultCallback::m_resultMax' [-Wreorder]
modules/bullet/godot_result_callbacks.h:93:2: warning:   when initialized here [-Wreorder]
modules/bullet/godot_result_callbacks.h:142:18: warning: 'GodotAllContactResultCallback::m_exclude' will be initialized after [-Wreorder]
modules/bullet/godot_result_callbacks.h:140:6: warning:   'int GodotAllContactResultCallback::m_resultMax' [-Wreorder]
modules/bullet/godot_result_callbacks.h:147:2: warning:   when initialized here [-Wreorder]
modules/bullet/godot_result_callbacks.h:168:18: warning: 'GodotContactPairContactResultCallback::m_exclude' will be initialized after [-Wreorder]
modules/bullet/godot_result_callbacks.h:166:6: warning:   'int GodotContactPairContactResultCallback::m_resultMax' [-Wreorder]
modules/bullet/godot_result_callbacks.h:173:2: warning:   when initialized here [-Wreorder]
modules/bullet/godot_result_callbacks.h:195:18: warning: 'GodotRestInfoContactResultCallback::m_exclude' will be initialized after [-Wreorder]
modules/bullet/godot_result_callbacks.h:191:7: warning:   'bool GodotRestInfoContactResultCallback::m_collided' [-Wreorder]
modules/bullet/godot_result_callbacks.h:199:2: warning:   when initialized here [-Wreorder]
modules/bullet/rigid_body_bullet.h:200:9: warning: 'RigidBodyBullet::gravity_scale' will be initialized after [-Wreorder]
modules/bullet/rigid_body_bullet.h:199:9: warning:   'real_t RigidBodyBullet::mass' [-Wreorder]
modules/bullet/rigid_body_bullet.cpp:258:1: warning:   when initialized here [-Wreorder]
modules/bullet/rigid_body_bullet.h:222:28: warning: 'RigidBodyBullet::force_integration_callback' will be initialized after [-Wreorder]
modules/bullet/rigid_body_bullet.h:219:7: warning:   'bool RigidBodyBullet::isTransformChanged' [-Wreorder]
modules/bullet/rigid_body_bullet.cpp:258:1: warning:   when initialized here [-Wreorder]
modules/bullet/rigid_body_bullet.h:220:7: warning: 'RigidBodyBullet::previousActiveState' will be initialized after [-Wreorder]
modules/bullet/rigid_body_bullet.h:208:6: warning:   'int RigidBodyBullet::maxCollisionsDetection' [-Wreorder]
modules/bullet/rigid_body_bullet.cpp:258:1: warning:   when initialized here [-Wreorder]
modules/bullet/soft_body_bullet.h:69:9: warning: 'SoftBodyBullet::total_mass' will be initialized after [-Wreorder]
modules/bullet/soft_body_bullet.h:68:6: warning:   'int SoftBodyBullet::simulation_precision' [-Wreorder]
modules/bullet/soft_body_bullet.cpp:38:1: warning:   when initialized here [-Wreorder]
modules/bullet/soft_body_bullet.h:76:9: warning: 'SoftBodyBullet::drag_coefficient' will be initialized after [-Wreorder]
modules/bullet/soft_body_bullet.h:61:14: warning:   'btSoftBody* SoftBodyBullet::bt_soft_body' [-Wreorder]
modules/bullet/soft_body_bullet.cpp:38:1: warning:   when initialized here [-Wreorder]
modules/bullet/space_bullet.h:97:22: warning: 'SpaceBullet::solver' will be initialized after [-Wreorder]
modules/bullet/space_bullet.h:95:35: warning:   'btDefaultCollisionConfiguration* SpaceBullet::collisionConfiguration' [-Wreorder]
modules/bullet/space_bullet.cpp:333:1: warning:   when initialized here [-Wreorder]
modules/bullet/space_bullet.h:101:23: warning: 'SpaceBullet::soft_body_world_info' will be initialized after [-Wreorder]
modules/bullet/space_bullet.h:99:23: warning:   'btGhostPairCallback* SpaceBullet::ghostPairCallback' [-Wreorder]
modules/bullet/space_bullet.cpp:333:1: warning:   when initialized here [-Wreorder]
modules/gdnative/nativescript/nativescript.h:79:13: warning: 'NativeScriptDesc::base_native_type' will be initialized after [-Wreorder]
modules/gdnative/nativescript/nativescript.h:73:9: warning:   'String NativeScriptDesc::documentation' [-Wreorder]
modules/gdnative/nativescript/nativescript.h:88:9: warning:   when initialized here [-Wreorder]
modules/gdscript/gdscript.h:296:6: warning: 'GDScriptWarning::line' will be initialized after [-Wreorder]
modules/gdscript/gdscript.h:294:4: warning:   'GDScriptWarning::Code GDScriptWarning::code' [-Wreorder]
modules/gdscript/gdscript.h:303:2: warning:   when initialized here [-Wreorder]
scene/3d/physics_body.h:544:7: warning: 'PhysicalBone::simulate_physics' will be initialized after [-Wreorder]
scene/3d/physics_body.h:543:7: warning:   'bool PhysicalBone::_internal_static_body' [-Wreorder]
scene/3d/physics_body.cpp:2502:1: warning:   when initialized here [-Wreorder]
scene/3d/physics_body.h:546:6: warning: 'PhysicalBone::bone_id' will be initialized after [-Wreorder]
scene/3d/physics_body.h:539:12: warning:   'Skeleton* PhysicalBone::parent_skeleton' [-Wreorder]
scene/3d/physics_body.cpp:2502:1: warning:   when initialized here [-Wreorder]
scene/3d/spring_arm.h:44:11: warning: 'SpringArm::mask' will be initialized after [-Wreorder]
scene/3d/spring_arm.h:43:8: warning:   'float SpringArm::current_spring_length' [-Wreorder]
scene/3d/spring_arm.cpp:37:1: warning:   when initialized here [-Wreorder]
scene/animation/skeleton_ik.h:159:11: warning: 'SkeletonIK::target_node_override' will be initialized after [-Wreorder]
scene/animation/skeleton_ik.h:152:7: warning:   'bool SkeletonIK::use_magnet' [-Wreorder]
scene/animation/skeleton_ik.cpp:418:1: warning:   when initialized here [-Wreorder]
scene/resources/tile_set.h:84:9: warning: 'TileSet::AutotileData::size' will be initialized after [-Wreorder]
scene/resources/tile_set.h:83:7: warning:   'int TileSet::AutotileData::spacing' [-Wreorder]
scene/resources/tile_set.h:92:12: warning:   when initialized here [-Wreorder]
scene/resources/tile_set.h:115:12: warning: 'TileSet::TileData::tile_mode' will be initialized after [-Wreorder]
scene/resources/tile_set.h:114:9: warning:   'Color TileSet::TileData::modulate' [-Wreorder]
scene/resources/tile_set.h:120:12: warning:   when initialized here [-Wreorder]
servers/physics/body_sw.h:84:19: warning: 'BodySW::direct_state_query_list' will be initialized after [-Wreorder]
servers/physics/body_sw.h:57:11: warning:   'uint16_t BodySW::locked_axis' [-Wreorder]
servers/physics/body_sw.cpp:756:1: warning:   when initialized here [-Wreorder]
```

Nothing really relevant for us, but it's not a bad consistency
improvement anyway so worth taking.
2018-09-28 17:30:28 +02:00

249 lines
8.9 KiB
C++

/*************************************************************************/
/* tile_set.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef TILE_SET_H
#define TILE_SET_H
#include "core/array.h"
#include "core/resource.h"
#include "scene/2d/light_occluder_2d.h"
#include "scene/2d/navigation_polygon.h"
#include "scene/resources/shape_2d.h"
#include "scene/resources/texture.h"
class TileSet : public Resource {
GDCLASS(TileSet, Resource);
public:
struct ShapeData {
Ref<Shape2D> shape;
Transform2D shape_transform;
Vector2 autotile_coord;
bool one_way_collision;
ShapeData() {
one_way_collision = false;
}
};
enum BitmaskMode {
BITMASK_2X2,
BITMASK_3X3_MINIMAL,
BITMASK_3X3
};
enum AutotileBindings {
BIND_TOPLEFT = 1,
BIND_TOP = 2,
BIND_TOPRIGHT = 4,
BIND_LEFT = 8,
BIND_CENTER = 16,
BIND_RIGHT = 32,
BIND_BOTTOMLEFT = 64,
BIND_BOTTOM = 128,
BIND_BOTTOMRIGHT = 256
};
enum TileMode {
SINGLE_TILE,
AUTO_TILE,
ATLAS_TILE
};
struct AutotileData {
BitmaskMode bitmask_mode;
Size2 size;
int spacing;
Vector2 icon_coord;
Map<Vector2, uint16_t> flags;
Map<Vector2, Ref<OccluderPolygon2D> > occluder_map;
Map<Vector2, Ref<NavigationPolygon> > navpoly_map;
Map<Vector2, int> priority_map;
// Default size to prevent invalid value
explicit AutotileData() :
bitmask_mode(BITMASK_2X2),
size(64, 64),
spacing(0),
icon_coord(0, 0) {}
};
private:
struct TileData {
String name;
Ref<Texture> texture;
Ref<Texture> normal_map;
Vector2 offset;
Rect2i region;
Vector<ShapeData> shapes_data;
Vector2 occluder_offset;
Ref<OccluderPolygon2D> occluder;
Vector2 navigation_polygon_offset;
Ref<NavigationPolygon> navigation_polygon;
Ref<ShaderMaterial> material;
TileMode tile_mode;
Color modulate;
AutotileData autotile_data;
int z_index;
// Default modulate for back-compat
explicit TileData() :
tile_mode(SINGLE_TILE),
modulate(1, 1, 1),
z_index(0) {}
};
Map<int, TileData> tile_map;
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;
void _tile_set_shapes(int p_id, const Array &p_shapes);
Array _tile_get_shapes(int p_id) const;
Array _get_tiles_ids() const;
static void _bind_methods();
public:
void create_tile(int p_id);
void autotile_set_bitmask_mode(int p_id, BitmaskMode p_mode);
BitmaskMode autotile_get_bitmask_mode(int p_id) const;
void tile_set_name(int p_id, const String &p_name);
String tile_get_name(int p_id) const;
void tile_set_texture(int p_id, const Ref<Texture> &p_texture);
Ref<Texture> tile_get_texture(int p_id) const;
void tile_set_normal_map(int p_id, const Ref<Texture> &p_normal_map);
Ref<Texture> tile_get_normal_map(int p_id) const;
void tile_set_texture_offset(int p_id, const Vector2 &p_offset);
Vector2 tile_get_texture_offset(int p_id) const;
void tile_set_region(int p_id, const Rect2 &p_region);
Rect2 tile_get_region(int p_id) const;
void tile_set_tile_mode(int p_id, TileMode p_tile_mode);
TileMode tile_get_tile_mode(int p_id) const;
void autotile_set_icon_coordinate(int p_id, Vector2 coord);
Vector2 autotile_get_icon_coordinate(int p_id) const;
void autotile_set_spacing(int p_id, int p_spacing);
int autotile_get_spacing(int p_id) const;
void autotile_set_size(int p_id, Size2 p_size);
Size2 autotile_get_size(int p_id) const;
void autotile_clear_bitmask_map(int p_id);
void autotile_set_subtile_priority(int p_id, const Vector2 &p_coord, int p_priority);
int autotile_get_subtile_priority(int p_id, const Vector2 &p_coord);
const Map<Vector2, int> &autotile_get_priority_map(int p_id) const;
void autotile_set_bitmask(int p_id, Vector2 p_coord, uint16_t p_flag);
uint16_t autotile_get_bitmask(int p_id, Vector2 p_coord);
const Map<Vector2, uint16_t> &autotile_get_bitmask_map(int p_id);
Vector2 autotile_get_subtile_for_bitmask(int p_id, uint16_t p_bitmask, const Node *p_tilemap_node = NULL, const Vector2 &p_tile_location = Vector2());
void tile_set_shape(int p_id, int p_shape_id, const Ref<Shape2D> &p_shape);
Ref<Shape2D> tile_get_shape(int p_id, int p_shape_id) const;
void tile_set_shape_transform(int p_id, int p_shape_id, const Transform2D &p_offset);
Transform2D tile_get_shape_transform(int p_id, int p_shape_id) const;
void tile_set_shape_offset(int p_id, int p_shape_id, const Vector2 &p_offset);
Vector2 tile_get_shape_offset(int p_id, int p_shape_id) const;
void tile_set_shape_one_way(int p_id, int p_shape_id, bool p_one_way);
bool tile_get_shape_one_way(int p_id, int p_shape_id) const;
void tile_clear_shapes(int p_id);
void tile_add_shape(int p_id, const Ref<Shape2D> &p_shape, const Transform2D &p_transform, bool p_one_way = false, const Vector2 &p_autotile_coord = Vector2());
int tile_get_shape_count(int p_id) const;
void tile_set_shapes(int p_id, const Vector<ShapeData> &p_shapes);
Vector<ShapeData> tile_get_shapes(int p_id) const;
void tile_set_material(int p_id, const Ref<ShaderMaterial> &p_material);
Ref<ShaderMaterial> tile_get_material(int p_id) const;
void tile_set_modulate(int p_id, const Color &p_modulate);
Color tile_get_modulate(int p_id) const;
void tile_set_occluder_offset(int p_id, const Vector2 &p_offset);
Vector2 tile_get_occluder_offset(int p_id) const;
void tile_set_light_occluder(int p_id, const Ref<OccluderPolygon2D> &p_light_occluder);
Ref<OccluderPolygon2D> tile_get_light_occluder(int p_id) const;
void autotile_set_light_occluder(int p_id, const Ref<OccluderPolygon2D> &p_light_occluder, const Vector2 &p_coord);
Ref<OccluderPolygon2D> autotile_get_light_occluder(int p_id, const Vector2 &p_coord) const;
const Map<Vector2, Ref<OccluderPolygon2D> > &autotile_get_light_oclusion_map(int p_id) const;
void tile_set_navigation_polygon_offset(int p_id, const Vector2 &p_offset);
Vector2 tile_get_navigation_polygon_offset(int p_id) const;
void tile_set_navigation_polygon(int p_id, const Ref<NavigationPolygon> &p_navigation_polygon);
Ref<NavigationPolygon> tile_get_navigation_polygon(int p_id) const;
void autotile_set_navigation_polygon(int p_id, const Ref<NavigationPolygon> &p_navigation_polygon, const Vector2 &p_coord);
Ref<NavigationPolygon> autotile_get_navigation_polygon(int p_id, const Vector2 &p_coord) const;
const Map<Vector2, Ref<NavigationPolygon> > &autotile_get_navigation_map(int p_id) const;
void tile_set_z_index(int p_id, int p_z_index);
int tile_get_z_index(int p_id) const;
void remove_tile(int p_id);
bool has_tile(int p_id) const;
bool is_tile_bound(int p_drawn_id, int p_neighbor_id);
int find_tile_by_name(const String &p_name) const;
void get_tile_list(List<int> *p_tiles) const;
void clear();
int get_last_unused_tile_id() const;
TileSet();
};
VARIANT_ENUM_CAST(TileSet::AutotileBindings);
VARIANT_ENUM_CAST(TileSet::BitmaskMode);
VARIANT_ENUM_CAST(TileSet::TileMode);
#endif // TILE_SET_H