mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-21 16:37:20 +01:00
Removed the gridmap.
This commit is contained in:
parent
85f907a253
commit
408e6ff56d
@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
Import("env")
|
||||
Import("env_modules")
|
||||
|
||||
env_gridmap = env_modules.Clone()
|
||||
|
||||
env_gridmap.add_source_files(env.modules_sources, "*.cpp")
|
@ -1,16 +0,0 @@
|
||||
def can_build(env, platform):
|
||||
return True
|
||||
|
||||
|
||||
def configure(env):
|
||||
pass
|
||||
|
||||
|
||||
def get_doc_classes():
|
||||
return [
|
||||
"GridMap",
|
||||
]
|
||||
|
||||
|
||||
def get_doc_path():
|
||||
return "doc_classes"
|
@ -1,213 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GridMap" inherits="Spatial" version="3.5">
|
||||
<brief_description>
|
||||
Node for 3D tile-based maps.
|
||||
</brief_description>
|
||||
<description>
|
||||
GridMap lets you place meshes on a grid interactively. It works both from the editor and from scripts, which can help you create in-game level editors.
|
||||
GridMaps use a [MeshLibrary] which contains a list of tiles. Each tile is a mesh with materials plus optional collision and navigation shapes.
|
||||
A GridMap contains a collection of cells. Each grid cell refers to a tile in the [MeshLibrary]. All cells in the map have the same dimensions.
|
||||
Internally, a GridMap is split into a sparse collection of octants for efficient rendering and physics processing. Every octant has the same dimensions and can contain several cells.
|
||||
[b]Note:[/b] GridMap doesn't extend [VisualInstance] and therefore can't be hidden or cull masked based on [member VisualInstance.layers]. If you make a light not affect the first layer, the whole GridMap won't be lit by the light in question.
|
||||
</description>
|
||||
<tutorials>
|
||||
<link title="Using gridmaps">$DOCS_URL/tutorials/3d/using_gridmaps.html</link>
|
||||
<link title="3D Platformer Demo">https://godotengine.org/asset-library/asset/125</link>
|
||||
<link title="3D Kinematic Character Demo">https://godotengine.org/asset-library/asset/126</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="clear">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Clear all cells.
|
||||
</description>
|
||||
</method>
|
||||
<method name="clear_baked_meshes">
|
||||
<return type="void" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_bake_mesh_instance">
|
||||
<return type="RID" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_bake_meshes">
|
||||
<return type="Array" />
|
||||
<description>
|
||||
Returns an array of [ArrayMesh]es and [Transform] references of all bake meshes that exist within the current GridMap.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_cell_item" qualifiers="const">
|
||||
<return type="int" />
|
||||
<argument index="0" name="x" type="int" />
|
||||
<argument index="1" name="y" type="int" />
|
||||
<argument index="2" name="z" type="int" />
|
||||
<description>
|
||||
The [MeshLibrary] item index located at the grid-based X, Y and Z coordinates. If the cell is empty, [constant INVALID_CELL_ITEM] will be returned.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_cell_item_orientation" qualifiers="const">
|
||||
<return type="int" />
|
||||
<argument index="0" name="x" type="int" />
|
||||
<argument index="1" name="y" type="int" />
|
||||
<argument index="2" name="z" type="int" />
|
||||
<description>
|
||||
The orientation of the cell at the grid-based X, Y and Z coordinates. -1 is returned if the cell is empty.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_layer_bit" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="bit" type="int" />
|
||||
<description>
|
||||
Returns an individual bit on the [member collision_layer].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_mask_bit" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="bit" type="int" />
|
||||
<description>
|
||||
Returns an individual bit on the [member collision_mask].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_meshes" qualifiers="const">
|
||||
<return type="Array" />
|
||||
<description>
|
||||
Returns an array of [Transform] and [Mesh] references corresponding to the non-empty cells in the grid. The transforms are specified in world space.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_used_cells" qualifiers="const">
|
||||
<return type="Array" />
|
||||
<description>
|
||||
Returns an array of [Vector3] with the non-empty cell coordinates in the grid map.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_used_cells_by_item" qualifiers="const">
|
||||
<return type="Array" />
|
||||
<argument index="0" name="item" type="int" />
|
||||
<description>
|
||||
Returns an array of all cells with the given item index specified in [code]item[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="make_baked_meshes">
|
||||
<return type="void" />
|
||||
<argument index="0" name="gen_lightmap_uv" type="bool" default="false" />
|
||||
<argument index="1" name="lightmap_uv_texel_size" type="float" default="0.1" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="map_to_world" qualifiers="const">
|
||||
<return type="Vector3" />
|
||||
<argument index="0" name="x" type="int" />
|
||||
<argument index="1" name="y" type="int" />
|
||||
<argument index="2" name="z" type="int" />
|
||||
<description>
|
||||
Returns the position of a grid cell in the GridMap's local coordinate space.
|
||||
</description>
|
||||
</method>
|
||||
<method name="resource_changed">
|
||||
<return type="void" />
|
||||
<argument index="0" name="resource" type="Resource" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_cell_item">
|
||||
<return type="void" />
|
||||
<argument index="0" name="x" type="int" />
|
||||
<argument index="1" name="y" type="int" />
|
||||
<argument index="2" name="z" type="int" />
|
||||
<argument index="3" name="item" type="int" />
|
||||
<argument index="4" name="orientation" type="int" default="0" />
|
||||
<description>
|
||||
Sets the mesh index for the cell referenced by its grid-based X, Y and Z coordinates.
|
||||
A negative item index such as [constant INVALID_CELL_ITEM] will clear the cell.
|
||||
Optionally, the item's orientation can be passed. For valid orientation values, see [method Basis.get_orthogonal_index].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_clip">
|
||||
<return type="void" />
|
||||
<argument index="0" name="enabled" type="bool" />
|
||||
<argument index="1" name="clipabove" type="bool" default="true" />
|
||||
<argument index="2" name="floor" type="int" default="0" />
|
||||
<argument index="3" name="axis" type="int" enum="Vector3.Axis" default="0" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_layer_bit">
|
||||
<return type="void" />
|
||||
<argument index="0" name="bit" type="int" />
|
||||
<argument index="1" name="value" type="bool" />
|
||||
<description>
|
||||
Sets an individual bit on the [member collision_layer].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_mask_bit">
|
||||
<return type="void" />
|
||||
<argument index="0" name="bit" type="int" />
|
||||
<argument index="1" name="value" type="bool" />
|
||||
<description>
|
||||
Sets an individual bit on the [member collision_mask].
|
||||
</description>
|
||||
</method>
|
||||
<method name="world_to_map" qualifiers="const">
|
||||
<return type="Vector3" />
|
||||
<argument index="0" name="pos" type="Vector3" />
|
||||
<description>
|
||||
Returns the coordinates of the grid cell containing the given point.
|
||||
[code]pos[/code] should be in the GridMap's local coordinate space.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="cell_center_x" type="bool" setter="set_center_x" getter="get_center_x" default="true">
|
||||
If [code]true[/code], grid items are centered on the X axis.
|
||||
</member>
|
||||
<member name="cell_center_y" type="bool" setter="set_center_y" getter="get_center_y" default="true">
|
||||
If [code]true[/code], grid items are centered on the Y axis.
|
||||
</member>
|
||||
<member name="cell_center_z" type="bool" setter="set_center_z" getter="get_center_z" default="true">
|
||||
If [code]true[/code], grid items are centered on the Z axis.
|
||||
</member>
|
||||
<member name="cell_octant_size" type="int" setter="set_octant_size" getter="get_octant_size" default="8">
|
||||
The size of each octant measured in number of cells. This applies to all three axis.
|
||||
</member>
|
||||
<member name="cell_scale" type="float" setter="set_cell_scale" getter="get_cell_scale" default="1.0">
|
||||
The scale of the cell items.
|
||||
This does not affect the size of the grid cells themselves, only the items in them. This can be used to make cell items overlap their neighbors.
|
||||
</member>
|
||||
<member name="cell_size" type="Vector3" setter="set_cell_size" getter="get_cell_size" default="Vector3( 2, 2, 2 )">
|
||||
The dimensions of the grid's cells.
|
||||
This does not affect the size of the meshes. See [member cell_scale].
|
||||
</member>
|
||||
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
|
||||
The physics layers this GridMap is in.
|
||||
GridMaps act as static bodies, meaning they aren't affected by gravity or other forces. They only affect other physics bodies that collide with them.
|
||||
</member>
|
||||
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
|
||||
The physics layers this GridMap detects collisions in. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
|
||||
</member>
|
||||
<member name="mesh_library" type="MeshLibrary" setter="set_mesh_library" getter="get_mesh_library">
|
||||
The assigned [MeshLibrary].
|
||||
</member>
|
||||
<member name="physics_material" type="PhysicsMaterial" setter="set_physics_material" getter="get_physics_material">
|
||||
Overrides the default friction and bounce physics properties for the whole [GridMap].
|
||||
</member>
|
||||
<member name="use_in_baked_light" type="bool" setter="set_use_in_baked_light" getter="get_use_in_baked_light" default="false">
|
||||
Controls whether this GridMap will be baked in a [BakedLightmap] or not.
|
||||
</member>
|
||||
</members>
|
||||
<signals>
|
||||
<signal name="cell_size_changed">
|
||||
<argument index="0" name="cell_size" type="Vector3" />
|
||||
<description>
|
||||
Emitted when [member cell_size] changes.
|
||||
</description>
|
||||
</signal>
|
||||
</signals>
|
||||
<constants>
|
||||
<constant name="INVALID_CELL_ITEM" value="-1">
|
||||
Invalid cell item that can be used in [method set_cell_item] to clear cells (or represent an empty cell in [method get_cell_item]).
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
File diff suppressed because it is too large
Load Diff
@ -1,278 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* grid_map.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 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 GRID_MAP_H
|
||||
#define GRID_MAP_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 PhysicsMaterial;
|
||||
|
||||
class GridMap : public Spatial {
|
||||
GDCLASS(GridMap, Spatial);
|
||||
|
||||
enum {
|
||||
MAP_DIRTY_TRANSFORMS = 1,
|
||||
MAP_DIRTY_INSTANCES = 2,
|
||||
};
|
||||
|
||||
union IndexKey {
|
||||
struct {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t z;
|
||||
};
|
||||
uint64_t key;
|
||||
|
||||
_FORCE_INLINE_ bool operator<(const IndexKey &p_key) const {
|
||||
return key < p_key.key;
|
||||
}
|
||||
|
||||
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 {
|
||||
unsigned int item : 16;
|
||||
unsigned int rot : 5;
|
||||
unsigned int layer : 8;
|
||||
};
|
||||
uint32_t cell;
|
||||
|
||||
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 NavMesh {
|
||||
RID region;
|
||||
Transform xform;
|
||||
};
|
||||
|
||||
struct MultimeshInstance {
|
||||
RID instance;
|
||||
RID multimesh;
|
||||
struct Item {
|
||||
int index;
|
||||
Transform transform;
|
||||
IndexKey key;
|
||||
};
|
||||
|
||||
Vector<Item> items; //tools only, for changing visibility
|
||||
};
|
||||
|
||||
Vector<MultimeshInstance> multimesh_instances;
|
||||
Set<IndexKey> cells;
|
||||
RID collision_debug;
|
||||
RID collision_debug_instance;
|
||||
|
||||
bool dirty;
|
||||
RID static_body;
|
||||
Map<IndexKey, NavMesh> navmesh_ids;
|
||||
};
|
||||
|
||||
union OctantKey {
|
||||
struct {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t z;
|
||||
int16_t empty;
|
||||
};
|
||||
|
||||
uint64_t key;
|
||||
|
||||
_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; }
|
||||
};
|
||||
|
||||
uint32_t collision_layer;
|
||||
uint32_t collision_mask;
|
||||
Ref<PhysicsMaterial> physics_material;
|
||||
|
||||
Transform last_transform;
|
||||
|
||||
bool _in_tree;
|
||||
Vector3 cell_size;
|
||||
int octant_size;
|
||||
bool center_x, center_y, center_z;
|
||||
float cell_scale;
|
||||
Navigation *navigation;
|
||||
|
||||
bool clip;
|
||||
bool clip_above;
|
||||
int clip_floor;
|
||||
|
||||
bool recreating_octants;
|
||||
|
||||
Vector3::Axis clip_axis;
|
||||
|
||||
Ref<MeshLibrary> mesh_library;
|
||||
bool use_in_baked_light;
|
||||
|
||||
Map<OctantKey, Octant *> octant_map;
|
||||
Map<IndexKey, Cell> cell_map;
|
||||
|
||||
void _recreate_octant_data();
|
||||
|
||||
struct BakeLight {
|
||||
VS::LightType type;
|
||||
Vector3 pos;
|
||||
Vector3 dir;
|
||||
float param[VS::LIGHT_PARAM_MAX];
|
||||
};
|
||||
|
||||
_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;
|
||||
}
|
||||
|
||||
void _reset_physic_bodies_collision_filters();
|
||||
void _octant_enter_world(const OctantKey &p_key);
|
||||
void _octant_exit_world(const OctantKey &p_key);
|
||||
bool _octant_update(const OctantKey &p_key);
|
||||
void _octant_clean_up(const OctantKey &p_key);
|
||||
void _octant_transform(const OctantKey &p_key);
|
||||
bool awaiting_update;
|
||||
|
||||
void _queue_octants_dirty();
|
||||
void _update_octants_callback();
|
||||
|
||||
void resource_changed(const RES &p_res);
|
||||
|
||||
void _clear_internal();
|
||||
|
||||
Vector3 _get_offset() const;
|
||||
|
||||
struct BakedMesh {
|
||||
Ref<Mesh> mesh;
|
||||
RID instance;
|
||||
};
|
||||
|
||||
Vector<BakedMesh> baked_meshes;
|
||||
|
||||
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 _notification(int p_what);
|
||||
void _update_visibility();
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
enum {
|
||||
INVALID_CELL_ITEM = -1
|
||||
};
|
||||
|
||||
void set_collision_layer(uint32_t p_layer);
|
||||
uint32_t get_collision_layer() const;
|
||||
|
||||
void set_collision_mask(uint32_t p_mask);
|
||||
uint32_t get_collision_mask() const;
|
||||
|
||||
void set_collision_layer_bit(int p_bit, bool p_value);
|
||||
bool get_collision_layer_bit(int p_bit) const;
|
||||
|
||||
void set_collision_mask_bit(int p_bit, bool p_value);
|
||||
bool get_collision_mask_bit(int p_bit) const;
|
||||
|
||||
void set_physics_material(Ref<PhysicsMaterial> p_material);
|
||||
Ref<PhysicsMaterial> get_physics_material() const;
|
||||
|
||||
Array get_collision_shapes() const;
|
||||
|
||||
void set_mesh_library(const Ref<MeshLibrary> &p_mesh_library);
|
||||
Ref<MeshLibrary> get_mesh_library() const;
|
||||
|
||||
void set_use_in_baked_light(bool p_use_baked_light);
|
||||
bool get_use_in_baked_light() const;
|
||||
|
||||
void set_cell_size(const Vector3 &p_size);
|
||||
Vector3 get_cell_size() const;
|
||||
|
||||
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);
|
||||
bool get_center_y() const;
|
||||
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_rot = 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;
|
||||
|
||||
Vector3 world_to_map(const Vector3 &p_world_pos) const;
|
||||
Vector3 map_to_world(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_cell_scale(float p_scale);
|
||||
float get_cell_scale() const;
|
||||
|
||||
Array get_used_cells() const;
|
||||
Array get_used_cells_by_item(int p_item) const;
|
||||
|
||||
Array get_meshes() const;
|
||||
|
||||
void clear_baked_meshes();
|
||||
void make_baked_meshes(bool p_gen_lightmap_uv = false, float p_lightmap_uv_texel_size = 0.1);
|
||||
|
||||
void clear();
|
||||
|
||||
Array get_bake_meshes();
|
||||
RID get_bake_mesh_instance(int p_idx);
|
||||
|
||||
GridMap();
|
||||
~GridMap();
|
||||
};
|
||||
|
||||
#endif // GRID_MAP_H
|
File diff suppressed because it is too large
Load Diff
@ -1,270 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* grid_map_editor_plugin.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 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 GRID_MAP_EDITOR_PLUGIN_H
|
||||
#define GRID_MAP_EDITOR_PLUGIN_H
|
||||
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_plugin.h"
|
||||
#include "editor/pane_drag.h"
|
||||
#include "grid_map.h"
|
||||
|
||||
class SpatialEditorPlugin;
|
||||
|
||||
class GridMapEditor : public VBoxContainer {
|
||||
GDCLASS(GridMapEditor, VBoxContainer);
|
||||
|
||||
enum {
|
||||
|
||||
GRID_CURSOR_SIZE = 50
|
||||
};
|
||||
|
||||
enum InputAction {
|
||||
|
||||
INPUT_NONE,
|
||||
INPUT_PAINT,
|
||||
INPUT_ERASE,
|
||||
INPUT_PICK,
|
||||
INPUT_SELECT,
|
||||
INPUT_PASTE,
|
||||
};
|
||||
|
||||
enum ClipMode {
|
||||
|
||||
CLIP_DISABLED,
|
||||
CLIP_ABOVE,
|
||||
CLIP_BELOW
|
||||
};
|
||||
|
||||
enum DisplayMode {
|
||||
DISPLAY_THUMBNAIL,
|
||||
DISPLAY_LIST
|
||||
};
|
||||
|
||||
UndoRedo *undo_redo;
|
||||
InputAction input_action;
|
||||
Panel *panel;
|
||||
MenuButton *options;
|
||||
SpinBox *floor;
|
||||
double accumulated_floor_delta;
|
||||
ToolButton *mode_thumbnail;
|
||||
ToolButton *mode_list;
|
||||
LineEdit *search_box;
|
||||
HSlider *size_slider;
|
||||
HBoxContainer *spatial_editor_hb;
|
||||
ConfirmationDialog *settings_dialog;
|
||||
VBoxContainer *settings_vbc;
|
||||
SpinBox *settings_pick_distance;
|
||||
Label *spin_box_label;
|
||||
|
||||
struct SetItem {
|
||||
Vector3 pos;
|
||||
int new_value;
|
||||
int new_orientation;
|
||||
int old_value;
|
||||
int old_orientation;
|
||||
};
|
||||
|
||||
List<SetItem> set_items;
|
||||
|
||||
GridMap *node;
|
||||
MeshLibrary *last_mesh_library;
|
||||
ClipMode clip_mode;
|
||||
|
||||
bool lock_view;
|
||||
Transform grid_xform;
|
||||
Transform edit_grid_xform;
|
||||
Vector3::Axis edit_axis;
|
||||
int edit_floor[3];
|
||||
Vector3 grid_ofs;
|
||||
|
||||
RID grid[3];
|
||||
RID grid_instance[3];
|
||||
RID cursor_instance;
|
||||
RID selection_mesh;
|
||||
RID selection_instance;
|
||||
RID selection_level_mesh[3];
|
||||
RID selection_level_instance[3];
|
||||
RID paste_mesh;
|
||||
RID paste_instance;
|
||||
|
||||
struct ClipboardItem {
|
||||
int cell_item;
|
||||
Vector3 grid_offset;
|
||||
int orientation;
|
||||
RID instance;
|
||||
};
|
||||
|
||||
List<ClipboardItem> clipboard_items;
|
||||
|
||||
Ref<SpatialMaterial> indicator_mat;
|
||||
Ref<SpatialMaterial> inner_mat;
|
||||
Ref<SpatialMaterial> outer_mat;
|
||||
Ref<SpatialMaterial> selection_floor_mat;
|
||||
|
||||
bool updating;
|
||||
|
||||
struct Selection {
|
||||
Vector3 click;
|
||||
Vector3 current;
|
||||
Vector3 begin;
|
||||
Vector3 end;
|
||||
bool active;
|
||||
} selection;
|
||||
Selection last_selection;
|
||||
|
||||
struct PasteIndicator {
|
||||
Vector3 click;
|
||||
Vector3 current;
|
||||
Vector3 begin;
|
||||
Vector3 end;
|
||||
int orientation;
|
||||
};
|
||||
PasteIndicator paste_indicator;
|
||||
|
||||
bool cursor_visible;
|
||||
Transform cursor_transform;
|
||||
|
||||
Vector3 cursor_origin;
|
||||
|
||||
int display_mode;
|
||||
int selected_palette;
|
||||
int cursor_rot;
|
||||
|
||||
enum Menu {
|
||||
|
||||
MENU_OPTION_NEXT_LEVEL,
|
||||
MENU_OPTION_PREV_LEVEL,
|
||||
MENU_OPTION_LOCK_VIEW,
|
||||
MENU_OPTION_CLIP_DISABLED,
|
||||
MENU_OPTION_CLIP_ABOVE,
|
||||
MENU_OPTION_CLIP_BELOW,
|
||||
MENU_OPTION_X_AXIS,
|
||||
MENU_OPTION_Y_AXIS,
|
||||
MENU_OPTION_Z_AXIS,
|
||||
MENU_OPTION_CURSOR_ROTATE_Y,
|
||||
MENU_OPTION_CURSOR_ROTATE_X,
|
||||
MENU_OPTION_CURSOR_ROTATE_Z,
|
||||
MENU_OPTION_CURSOR_BACK_ROTATE_Y,
|
||||
MENU_OPTION_CURSOR_BACK_ROTATE_X,
|
||||
MENU_OPTION_CURSOR_BACK_ROTATE_Z,
|
||||
MENU_OPTION_CURSOR_CLEAR_ROTATION,
|
||||
MENU_OPTION_PASTE_SELECTS,
|
||||
MENU_OPTION_SELECTION_DUPLICATE,
|
||||
MENU_OPTION_SELECTION_CUT,
|
||||
MENU_OPTION_SELECTION_CLEAR,
|
||||
MENU_OPTION_SELECTION_FILL,
|
||||
MENU_OPTION_GRIDMAP_SETTINGS
|
||||
|
||||
};
|
||||
|
||||
SpatialEditorPlugin *spatial_editor;
|
||||
|
||||
struct AreaDisplay {
|
||||
RID mesh;
|
||||
RID instance;
|
||||
};
|
||||
|
||||
ItemList *mesh_library_palette;
|
||||
Label *info_message;
|
||||
|
||||
EditorNode *editor;
|
||||
|
||||
void update_grid(); // Change which and where the grid is displayed
|
||||
void _draw_grids(const Vector3 &cell_size);
|
||||
void _configure();
|
||||
void _menu_option(int);
|
||||
void update_palette();
|
||||
void _set_display_mode(int p_mode);
|
||||
void _item_selected_cbk(int idx);
|
||||
void _update_cursor_transform();
|
||||
void _update_cursor_instance();
|
||||
void _update_clip();
|
||||
|
||||
void _text_changed(const String &p_text);
|
||||
void _sbox_input(const Ref<InputEvent> &p_ie);
|
||||
void _mesh_library_palette_input(const Ref<InputEvent> &p_ie);
|
||||
|
||||
void _icon_size_changed(float p_value);
|
||||
|
||||
void _clear_clipboard_data();
|
||||
void _set_clipboard_data();
|
||||
void _update_paste_indicator();
|
||||
void _do_paste();
|
||||
void _update_selection_transform();
|
||||
void _validate_selection();
|
||||
void _set_selection(bool p_active, const Vector3 &p_begin = Vector3(), const Vector3 &p_end = Vector3());
|
||||
|
||||
void _floor_changed(float p_value);
|
||||
void _floor_mouse_exited();
|
||||
|
||||
void _delete_selection();
|
||||
void _fill_selection();
|
||||
|
||||
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
|
||||
|
||||
friend class GridMapEditorPlugin;
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
void _node_removed(Node *p_node);
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
|
||||
|
||||
void edit(GridMap *p_gridmap);
|
||||
GridMapEditor() {}
|
||||
GridMapEditor(EditorNode *p_editor);
|
||||
~GridMapEditor();
|
||||
};
|
||||
|
||||
class GridMapEditorPlugin : public EditorPlugin {
|
||||
GDCLASS(GridMapEditorPlugin, EditorPlugin);
|
||||
|
||||
GridMapEditor *grid_map_editor;
|
||||
EditorNode *editor;
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
||||
public:
|
||||
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { return grid_map_editor->forward_spatial_input_event(p_camera, p_event); }
|
||||
virtual String get_name() const { return "GridMap"; }
|
||||
bool has_main_screen() const { return false; }
|
||||
virtual void edit(Object *p_object);
|
||||
virtual bool handles(Object *p_object) const;
|
||||
virtual void make_visible(bool p_visible);
|
||||
|
||||
GridMapEditorPlugin(EditorNode *p_node);
|
||||
~GridMapEditorPlugin();
|
||||
};
|
||||
|
||||
#endif // CUBE_GRID_MAP_EDITOR_PLUGIN_H
|
@ -1,5 +0,0 @@
|
||||
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<g transform="translate(0 -1036.4)">
|
||||
<path transform="translate(0 1036.4)" d="m8 1-6 3v8l6 3 6-3v-2l-2-1-4 2-2-1v-4l2-1v-2l2-1zm4 2-2 1v2l2 1 2-1v-2z" fill="#fc9c9c" fill-opacity=".99608"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 300 B |
@ -1,48 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* register_types.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 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. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "register_types.h"
|
||||
#ifndef _3D_DISABLED
|
||||
#include "core/class_db.h"
|
||||
#include "grid_map.h"
|
||||
#include "grid_map_editor_plugin.h"
|
||||
#endif
|
||||
|
||||
void register_gridmap_types() {
|
||||
#ifndef _3D_DISABLED
|
||||
ClassDB::register_class<GridMap>();
|
||||
#ifdef TOOLS_ENABLED
|
||||
EditorPlugins::add_by_type<GridMapEditorPlugin>();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void unregister_gridmap_types() {
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* register_types.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 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 GRIDMAP_REGISTER_TYPES_H
|
||||
#define GRIDMAP_REGISTER_TYPES_H
|
||||
|
||||
void register_gridmap_types();
|
||||
void unregister_gridmap_types();
|
||||
|
||||
#endif // GRIDMAP_REGISTER_TYPES_H
|
Loading…
Reference in New Issue
Block a user