initial commit, 4.5 stable
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
This commit is contained in:
12
modules/gridmap/SCsub
Normal file
12
modules/gridmap/SCsub
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
from misc.utility.scons_hints import *
|
||||
|
||||
Import("env")
|
||||
Import("env_modules")
|
||||
|
||||
env_gridmap = env_modules.Clone()
|
||||
|
||||
# Godot source files
|
||||
env_gridmap.add_source_files(env.modules_sources, "*.cpp")
|
||||
if env.editor_build:
|
||||
env_gridmap.add_source_files(env.modules_sources, "editor/*.cpp")
|
14
modules/gridmap/config.py
Normal file
14
modules/gridmap/config.py
Normal file
@@ -0,0 +1,14 @@
|
||||
def can_build(env, platform):
|
||||
return not env["disable_3d"]
|
||||
|
||||
|
||||
def configure(env):
|
||||
pass
|
||||
|
||||
|
||||
def get_doc_classes():
|
||||
return ["GridMap", "GridMapEditorPlugin"]
|
||||
|
||||
|
||||
def get_doc_path():
|
||||
return "doc_classes"
|
244
modules/gridmap/doc_classes/GridMap.xml
Normal file
244
modules/gridmap/doc_classes/GridMap.xml
Normal file
@@ -0,0 +1,244 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GridMap" inherits="Node3D" keywords="tilemap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
|
||||
<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 [VisualInstance3D] and therefore can't be hidden or cull masked based on [member VisualInstance3D.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/2748</link>
|
||||
<link title="3D Kinematic Character Demo">https://godotengine.org/asset-library/asset/2739</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="clear">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Clear all cells.
|
||||
</description>
|
||||
</method>
|
||||
<method name="clear_baked_meshes">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Clears all baked meshes. See [method make_baked_meshes].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_bake_mesh_instance">
|
||||
<return type="RID" />
|
||||
<param index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Returns [RID] of a baked mesh with the given [param idx].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_bake_meshes">
|
||||
<return type="Array" />
|
||||
<description>
|
||||
Returns an array of [ArrayMesh]es and [Transform3D] references of all bake meshes that exist within the current GridMap. Even indices contain [ArrayMesh]es, while odd indices contain [Transform3D]s that are always equal to [constant Transform3D.IDENTITY].
|
||||
This method relies on the output of [method make_baked_meshes], which will be called with [code]gen_lightmap_uv[/code] set to [code]true[/code] and [code]lightmap_uv_texel_size[/code] set to [code]0.1[/code] if it hasn't been called yet.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_basis_with_orthogonal_index" qualifiers="const">
|
||||
<return type="Basis" />
|
||||
<param index="0" name="index" type="int" />
|
||||
<description>
|
||||
Returns one of 24 possible rotations that lie along the vectors (x,y,z) with each component being either -1, 0, or 1. For further details, refer to the Godot source code.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_cell_item" qualifiers="const">
|
||||
<return type="int" />
|
||||
<param index="0" name="position" type="Vector3i" />
|
||||
<description>
|
||||
The [MeshLibrary] item index located at the given grid coordinates. If the cell is empty, [constant INVALID_CELL_ITEM] will be returned.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_cell_item_basis" qualifiers="const">
|
||||
<return type="Basis" />
|
||||
<param index="0" name="position" type="Vector3i" />
|
||||
<description>
|
||||
Returns the basis that gives the specified cell its orientation.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_cell_item_orientation" qualifiers="const">
|
||||
<return type="int" />
|
||||
<param index="0" name="position" type="Vector3i" />
|
||||
<description>
|
||||
The orientation of the cell at the given grid coordinates. [code]-1[/code] is returned if the cell is empty.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_layer_value" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="layer_number" type="int" />
|
||||
<description>
|
||||
Returns whether or not the specified layer of the [member collision_layer] is enabled, given a [param layer_number] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_mask_value" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="layer_number" type="int" />
|
||||
<description>
|
||||
Returns whether or not the specified layer of the [member collision_mask] is enabled, given a [param layer_number] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_meshes" qualifiers="const">
|
||||
<return type="Array" />
|
||||
<description>
|
||||
Returns an array of [Transform3D] and [Mesh] references corresponding to the non-empty cells in the grid. The transforms are specified in local space. Even indices contain [Transform3D]s, while odd indices contain [Mesh]es related to the [Transform3D] in the index preceding it.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_navigation_map" qualifiers="const">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
Returns the [RID] of the navigation map this GridMap node uses for its cell baked navigation meshes.
|
||||
This function returns always the map set on the GridMap node and not the map on the NavigationServer. If the map is changed directly with the NavigationServer API the GridMap node will not be aware of the map change.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_orthogonal_index_from_basis" qualifiers="const">
|
||||
<return type="int" />
|
||||
<param index="0" name="basis" type="Basis" />
|
||||
<description>
|
||||
This function considers a discretization of rotations into 24 points on unit sphere, lying along the vectors (x,y,z) with each component being either -1, 0, or 1, and returns the index (in the range from 0 to 23) of the point best representing the orientation of the object. For further details, refer to the Godot source code.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_used_cells" qualifiers="const">
|
||||
<return type="Vector3i[]" />
|
||||
<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="Vector3i[]" />
|
||||
<param index="0" name="item" type="int" />
|
||||
<description>
|
||||
Returns an array of all cells with the given item index specified in [param item].
|
||||
</description>
|
||||
</method>
|
||||
<method name="local_to_map" qualifiers="const">
|
||||
<return type="Vector3i" />
|
||||
<param index="0" name="local_position" type="Vector3" />
|
||||
<description>
|
||||
Returns the map coordinates of the cell containing the given [param local_position]. If [param local_position] is in global coordinates, consider using [method Node3D.to_local] before passing it to this method. See also [method map_to_local].
|
||||
</description>
|
||||
</method>
|
||||
<method name="make_baked_meshes">
|
||||
<return type="void" />
|
||||
<param index="0" name="gen_lightmap_uv" type="bool" default="false" />
|
||||
<param index="1" name="lightmap_uv_texel_size" type="float" default="0.1" />
|
||||
<description>
|
||||
Generates a baked mesh that represents all meshes in the assigned [MeshLibrary] for use with [LightmapGI]. If [param gen_lightmap_uv] is [code]true[/code], UV2 data will be generated for each mesh currently used in the [GridMap]. Otherwise, only meshes that already have UV2 data present will be able to use baked lightmaps. When generating UV2, [param lightmap_uv_texel_size] controls the texel density for lightmaps, with lower values resulting in more detailed lightmaps. [param lightmap_uv_texel_size] is ignored if [param gen_lightmap_uv] is [code]false[/code]. See also [method get_bake_meshes], which relies on the output of this method.
|
||||
[b]Note:[/b] Calling this method will not actually bake lightmaps, as lightmap baking is performed using the [LightmapGI] node.
|
||||
</description>
|
||||
</method>
|
||||
<method name="map_to_local" qualifiers="const">
|
||||
<return type="Vector3" />
|
||||
<param index="0" name="map_position" type="Vector3i" />
|
||||
<description>
|
||||
Returns the position of a grid cell in the GridMap's local coordinate space. To convert the returned value into global coordinates, use [method Node3D.to_global]. See also [method local_to_map].
|
||||
</description>
|
||||
</method>
|
||||
<method name="resource_changed" deprecated="Use [signal Resource.changed] instead.">
|
||||
<return type="void" />
|
||||
<param index="0" name="resource" type="Resource" />
|
||||
<description>
|
||||
This method does nothing.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_cell_item">
|
||||
<return type="void" />
|
||||
<param index="0" name="position" type="Vector3i" />
|
||||
<param index="1" name="item" type="int" />
|
||||
<param index="2" name="orientation" type="int" default="0" />
|
||||
<description>
|
||||
Sets the mesh index for the cell referenced by its grid 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 get_orthogonal_index_from_basis].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_layer_value">
|
||||
<return type="void" />
|
||||
<param index="0" name="layer_number" type="int" />
|
||||
<param index="1" name="value" type="bool" />
|
||||
<description>
|
||||
Based on [param value], enables or disables the specified layer in the [member collision_layer], given a [param layer_number] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_collision_mask_value">
|
||||
<return type="void" />
|
||||
<param index="0" name="layer_number" type="int" />
|
||||
<param index="1" name="value" type="bool" />
|
||||
<description>
|
||||
Based on [param value], enables or disables the specified layer in the [member collision_mask], given a [param layer_number] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_navigation_map">
|
||||
<return type="void" />
|
||||
<param index="0" name="navigation_map" type="RID" />
|
||||
<description>
|
||||
Sets the [RID] of the navigation map this GridMap node should use for its cell baked navigation meshes.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="bake_navigation" type="bool" setter="set_bake_navigation" getter="is_baking_navigation" default="false">
|
||||
If [code]true[/code], this GridMap creates a navigation region for each cell that uses a [member mesh_library] item with a navigation mesh. The created navigation region will use the navigation layers bitmask assigned to the [MeshLibrary]'s item.
|
||||
</member>
|
||||
<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="collision_priority" type="float" setter="set_collision_priority" getter="get_collision_priority" default="1.0">
|
||||
The priority used to solve colliding when occurring penetration. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.
|
||||
</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>
|
||||
</members>
|
||||
<signals>
|
||||
<signal name="cell_size_changed">
|
||||
<param index="0" name="cell_size" type="Vector3" />
|
||||
<description>
|
||||
Emitted when [member cell_size] changes.
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="changed">
|
||||
<description>
|
||||
Emitted when the [MeshLibrary] of this GridMap 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>
|
66
modules/gridmap/doc_classes/GridMapEditorPlugin.xml
Normal file
66
modules/gridmap/doc_classes/GridMapEditorPlugin.xml
Normal file
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GridMapEditorPlugin" inherits="EditorPlugin" keywords="tilemap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
|
||||
<brief_description>
|
||||
Editor for [GridMap] nodes.
|
||||
</brief_description>
|
||||
<description>
|
||||
GridMapEditorPlugin provides access to the [GridMap] editor functionality.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="clear_selection">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Deselects any currently selected cells.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_current_grid_map" qualifiers="const">
|
||||
<return type="GridMap" />
|
||||
<description>
|
||||
Returns the [GridMap] node currently edited by the grid map editor.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_selected_cells" qualifiers="const">
|
||||
<return type="Array" />
|
||||
<description>
|
||||
Returns an array of [Vector3i]s with the selected cells' coordinates.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_selected_palette_item" qualifiers="const">
|
||||
<return type="int" />
|
||||
<description>
|
||||
Returns the index of the selected [MeshLibrary] item in the grid map editor's palette or [code]-1[/code] if no item is selected.
|
||||
[b]Note:[/b] The indices might not be in the same order as they appear in the editor's interface.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_selection" qualifiers="const">
|
||||
<return type="AABB" />
|
||||
<description>
|
||||
Returns the cell coordinate bounds of the current selection. Use [method has_selection] to check if there is an active selection.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_selection" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if there are selected cells.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_selected_palette_item" qualifiers="const">
|
||||
<return type="void" />
|
||||
<param index="0" name="item" type="int" />
|
||||
<description>
|
||||
Selects the [MeshLibrary] item with the given index in the grid map editor's palette. If a negative index is given, no item will be selected. If a value greater than the last index is given, the last item will be selected.
|
||||
[b]Note:[/b] The indices might not be in the same order as they appear in the editor's interface.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_selection">
|
||||
<return type="void" />
|
||||
<param index="0" name="begin" type="Vector3i" />
|
||||
<param index="1" name="end" type="Vector3i" />
|
||||
<description>
|
||||
Selects the cells inside the given bounds from [param begin] to [param end].
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
</class>
|
1
modules/gridmap/doc_classes/README.md
Normal file
1
modules/gridmap/doc_classes/README.md
Normal file
@@ -0,0 +1 @@
|
||||
Doc classes will appear here when generating
|
1869
modules/gridmap/editor/grid_map_editor_plugin.cpp
Normal file
1869
modules/gridmap/editor/grid_map_editor_plugin.cpp
Normal file
File diff suppressed because it is too large
Load Diff
293
modules/gridmap/editor/grid_map_editor_plugin.h
Normal file
293
modules/gridmap/editor/grid_map_editor_plugin.h
Normal file
@@ -0,0 +1,293 @@
|
||||
/**************************************************************************/
|
||||
/* grid_map_editor_plugin.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../grid_map.h"
|
||||
|
||||
#include "editor/plugins/editor_plugin.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
#include "scene/gui/item_list.h"
|
||||
#include "scene/gui/slider.h"
|
||||
#include "scene/gui/spin_box.h"
|
||||
|
||||
class ConfirmationDialog;
|
||||
class MenuButton;
|
||||
class Node3DEditorPlugin;
|
||||
class ButtonGroup;
|
||||
class EditorZoomWidget;
|
||||
class BaseButton;
|
||||
|
||||
class GridMapEditor : public VBoxContainer {
|
||||
GDCLASS(GridMapEditor, VBoxContainer);
|
||||
|
||||
static constexpr int32_t GRID_CURSOR_SIZE = 50;
|
||||
|
||||
enum InputAction {
|
||||
INPUT_NONE,
|
||||
INPUT_TRANSFORM,
|
||||
INPUT_PAINT,
|
||||
INPUT_ERASE,
|
||||
INPUT_PICK,
|
||||
INPUT_SELECT,
|
||||
INPUT_PASTE,
|
||||
};
|
||||
|
||||
enum DisplayMode {
|
||||
DISPLAY_THUMBNAIL,
|
||||
DISPLAY_LIST
|
||||
};
|
||||
|
||||
InputAction input_action = INPUT_NONE;
|
||||
Panel *panel = nullptr;
|
||||
MenuButton *options = nullptr;
|
||||
SpinBox *floor = nullptr;
|
||||
double accumulated_floor_delta = 0.0;
|
||||
|
||||
HBoxContainer *toolbar = nullptr;
|
||||
TightLocalVector<BaseButton *> viewport_shortcut_buttons;
|
||||
Ref<ButtonGroup> mode_buttons_group;
|
||||
// mode
|
||||
Button *transform_mode_button = nullptr;
|
||||
Button *select_mode_button = nullptr;
|
||||
Button *erase_mode_button = nullptr;
|
||||
Button *paint_mode_button = nullptr;
|
||||
Button *pick_mode_button = nullptr;
|
||||
// action
|
||||
Button *fill_action_button = nullptr;
|
||||
Button *move_action_button = nullptr;
|
||||
Button *duplicate_action_button = nullptr;
|
||||
Button *delete_action_button = nullptr;
|
||||
// rotation
|
||||
Button *rotate_x_button = nullptr;
|
||||
Button *rotate_y_button = nullptr;
|
||||
Button *rotate_z_button = nullptr;
|
||||
|
||||
EditorZoomWidget *zoom_widget = nullptr;
|
||||
Button *mode_thumbnail = nullptr;
|
||||
Button *mode_list = nullptr;
|
||||
LineEdit *search_box = nullptr;
|
||||
HSlider *size_slider = nullptr;
|
||||
ConfirmationDialog *settings_dialog = nullptr;
|
||||
VBoxContainer *settings_vbc = nullptr;
|
||||
SpinBox *settings_pick_distance = nullptr;
|
||||
Label *spin_box_label = nullptr;
|
||||
|
||||
struct SetItem {
|
||||
Vector3i position;
|
||||
int new_value = 0;
|
||||
int new_orientation = 0;
|
||||
int old_value = 0;
|
||||
int old_orientation = 0;
|
||||
};
|
||||
|
||||
LocalVector<SetItem> set_items;
|
||||
|
||||
GridMap *node = nullptr;
|
||||
Ref<MeshLibrary> mesh_library = nullptr;
|
||||
|
||||
Transform3D grid_xform;
|
||||
Transform3D edit_grid_xform;
|
||||
Vector3::Axis edit_axis;
|
||||
int edit_floor[3];
|
||||
Vector3 grid_ofs;
|
||||
|
||||
RID grid[3];
|
||||
RID grid_instance[3];
|
||||
RID cursor_mesh;
|
||||
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 = 0;
|
||||
Vector3 grid_offset;
|
||||
int orientation = 0;
|
||||
RID instance;
|
||||
};
|
||||
|
||||
LocalVector<ClipboardItem> clipboard_items;
|
||||
|
||||
Color default_color;
|
||||
Color erase_color;
|
||||
Color pick_color;
|
||||
Ref<StandardMaterial3D> indicator_mat;
|
||||
Ref<StandardMaterial3D> cursor_inner_mat;
|
||||
Ref<StandardMaterial3D> cursor_outer_mat;
|
||||
Ref<StandardMaterial3D> inner_mat;
|
||||
Ref<StandardMaterial3D> outer_mat;
|
||||
Ref<StandardMaterial3D> selection_floor_mat;
|
||||
|
||||
bool updating = false;
|
||||
|
||||
struct Selection {
|
||||
Vector3 click;
|
||||
Vector3 current;
|
||||
Vector3 begin;
|
||||
Vector3 end;
|
||||
bool active = false;
|
||||
} selection;
|
||||
Selection last_selection;
|
||||
|
||||
struct PasteIndicator {
|
||||
Vector3 click;
|
||||
Vector3 current;
|
||||
Vector3 begin;
|
||||
Vector3 end;
|
||||
int orientation = 0;
|
||||
};
|
||||
PasteIndicator paste_indicator;
|
||||
|
||||
bool cursor_visible = false;
|
||||
Transform3D cursor_transform;
|
||||
|
||||
Vector3 cursor_origin;
|
||||
|
||||
int display_mode = DISPLAY_THUMBNAIL;
|
||||
int selected_palette = -1;
|
||||
int cursor_rot = 0;
|
||||
|
||||
enum Menu {
|
||||
MENU_OPTION_NEXT_LEVEL,
|
||||
MENU_OPTION_PREV_LEVEL,
|
||||
MENU_OPTION_LOCK_VIEW,
|
||||
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
|
||||
|
||||
};
|
||||
|
||||
Node3DEditorPlugin *spatial_editor = nullptr;
|
||||
|
||||
struct AreaDisplay {
|
||||
RID mesh;
|
||||
RID instance;
|
||||
};
|
||||
|
||||
ItemList *mesh_library_palette = nullptr;
|
||||
Label *info_message = nullptr;
|
||||
|
||||
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 _update_mesh_library();
|
||||
void _set_display_mode(int p_mode);
|
||||
void _item_selected_cbk(int idx);
|
||||
void _update_cursor_transform();
|
||||
void _update_cursor_instance();
|
||||
void _on_tool_mode_changed();
|
||||
void _update_theme();
|
||||
|
||||
void _text_changed(const String &p_text);
|
||||
void _sbox_input(const Ref<InputEvent> &p_event);
|
||||
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 _show_viewports_transform_gizmo(bool p_value);
|
||||
void _update_selection_transform();
|
||||
void _validate_selection();
|
||||
void _set_selection(bool p_active, const Vector3 &p_begin = Vector3(), const Vector3 &p_end = Vector3());
|
||||
AABB _get_selection() const;
|
||||
bool _has_selection() const;
|
||||
Array _get_selected_cells() const;
|
||||
|
||||
void _floor_changed(float p_value);
|
||||
void _floor_mouse_exited();
|
||||
|
||||
void _delete_selection();
|
||||
void _fill_selection();
|
||||
|
||||
bool do_input_action(Camera3D *p_camera, const Point2 &p_point, bool p_click);
|
||||
|
||||
friend class GridMapEditorPlugin;
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
EditorPlugin::AfterGUIInput forward_spatial_input_event(Camera3D *p_camera, const Ref<InputEvent> &p_event);
|
||||
|
||||
void edit(GridMap *p_gridmap);
|
||||
GridMapEditor();
|
||||
~GridMapEditor();
|
||||
};
|
||||
|
||||
class GridMapEditorPlugin : public EditorPlugin {
|
||||
GDCLASS(GridMapEditorPlugin, EditorPlugin);
|
||||
|
||||
GridMapEditor *grid_map_editor = nullptr;
|
||||
Button *panel_button = nullptr;
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual EditorPlugin::AfterGUIInput forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) override { return grid_map_editor->forward_spatial_input_event(p_camera, p_event); }
|
||||
virtual String get_plugin_name() const override { return "GridMap"; }
|
||||
bool has_main_screen() const override { return false; }
|
||||
virtual void edit(Object *p_object) override;
|
||||
virtual bool handles(Object *p_object) const override;
|
||||
virtual void make_visible(bool p_visible) override;
|
||||
|
||||
GridMap *get_current_grid_map() const;
|
||||
void set_selection(const Vector3i &p_begin, const Vector3i &p_end);
|
||||
void clear_selection();
|
||||
AABB get_selection() const;
|
||||
bool has_selection() const;
|
||||
Array get_selected_cells() const;
|
||||
void set_selected_palette_item(int p_item) const;
|
||||
int get_selected_palette_item() const;
|
||||
};
|
1732
modules/gridmap/grid_map.cpp
Normal file
1732
modules/gridmap/grid_map.cpp
Normal file
File diff suppressed because it is too large
Load Diff
328
modules/gridmap/grid_map.h
Normal file
328
modules/gridmap/grid_map.h
Normal file
@@ -0,0 +1,328 @@
|
||||
/**************************************************************************/
|
||||
/* grid_map.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "scene/3d/node_3d.h"
|
||||
#include "scene/resources/3d/mesh_library.h"
|
||||
#include "scene/resources/multimesh.h"
|
||||
|
||||
class NavigationMesh;
|
||||
class NavigationMeshSourceGeometryData3D;
|
||||
#ifndef PHYSICS_3D_DISABLED
|
||||
class PhysicsMaterial;
|
||||
#endif // PHYSICS_3D_DISABLED
|
||||
|
||||
class GridMap : public Node3D {
|
||||
GDCLASS(GridMap, Node3D);
|
||||
|
||||
enum {
|
||||
MAP_DIRTY_TRANSFORMS = 1,
|
||||
MAP_DIRTY_INSTANCES = 2,
|
||||
};
|
||||
|
||||
union IndexKey {
|
||||
struct {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t z;
|
||||
};
|
||||
uint64_t key = 0;
|
||||
|
||||
static uint32_t hash(const IndexKey &p_key) {
|
||||
return hash_one_uint64(p_key.key);
|
||||
}
|
||||
_FORCE_INLINE_ bool operator<(const IndexKey &p_key) const {
|
||||
return key < p_key.key;
|
||||
}
|
||||
_FORCE_INLINE_ bool operator==(const IndexKey &p_key) const {
|
||||
return key == p_key.key;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ operator Vector3i() const {
|
||||
return Vector3i(x, y, z);
|
||||
}
|
||||
|
||||
IndexKey(Vector3i p_vector) {
|
||||
x = (int16_t)p_vector.x;
|
||||
y = (int16_t)p_vector.y;
|
||||
z = (int16_t)p_vector.z;
|
||||
}
|
||||
IndexKey() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* @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 = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief An Octant is a prism containing Cells, and possibly belonging to an Area.
|
||||
* A GridMap can have multiple Octants.
|
||||
*/
|
||||
struct Octant {
|
||||
struct NavigationCell {
|
||||
RID region;
|
||||
Transform3D xform;
|
||||
RID navigation_mesh_debug_instance;
|
||||
uint32_t navigation_layers = 1;
|
||||
};
|
||||
|
||||
struct MultimeshInstance {
|
||||
RID instance;
|
||||
RID multimesh;
|
||||
struct Item {
|
||||
int index = 0;
|
||||
Transform3D transform;
|
||||
IndexKey key;
|
||||
};
|
||||
|
||||
Vector<Item> items; //tools only, for changing visibility
|
||||
};
|
||||
|
||||
Vector<MultimeshInstance> multimesh_instances;
|
||||
HashSet<IndexKey> cells;
|
||||
RID collision_debug;
|
||||
RID collision_debug_instance;
|
||||
#ifdef DEBUG_ENABLED
|
||||
RID navigation_debug_edge_connections_instance;
|
||||
Ref<ArrayMesh> navigation_debug_edge_connections_mesh;
|
||||
#endif // DEBUG_ENABLED
|
||||
|
||||
bool dirty = false;
|
||||
RID static_body;
|
||||
HashMap<IndexKey, NavigationCell> navigation_cell_ids;
|
||||
};
|
||||
|
||||
union OctantKey {
|
||||
struct {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t z;
|
||||
int16_t empty;
|
||||
};
|
||||
|
||||
uint64_t key = 0;
|
||||
|
||||
static uint32_t hash(const OctantKey &p_key) {
|
||||
return hash_one_uint64(p_key.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() {}
|
||||
};
|
||||
|
||||
OctantKey get_octant_key_from_index_key(const IndexKey &p_index_key) const;
|
||||
OctantKey get_octant_key_from_cell_coords(const Vector3i &p_cell_coords) const;
|
||||
|
||||
#ifndef PHYSICS_3D_DISABLED
|
||||
uint32_t collision_layer = 1;
|
||||
uint32_t collision_mask = 1;
|
||||
real_t collision_priority = 1.0;
|
||||
Ref<PhysicsMaterial> physics_material;
|
||||
#endif // PHYSICS_3D_DISABLED
|
||||
bool bake_navigation = false;
|
||||
RID map_override;
|
||||
|
||||
Transform3D last_transform;
|
||||
|
||||
bool _in_tree = false;
|
||||
Vector3 cell_size = Vector3(2, 2, 2);
|
||||
int octant_size = 8;
|
||||
bool center_x = true;
|
||||
bool center_y = true;
|
||||
bool center_z = true;
|
||||
float cell_scale = 1.0;
|
||||
|
||||
bool recreating_octants = false;
|
||||
|
||||
Ref<MeshLibrary> mesh_library;
|
||||
|
||||
HashMap<OctantKey, Octant *, OctantKey> octant_map;
|
||||
HashMap<IndexKey, Cell, IndexKey> cell_map;
|
||||
|
||||
void _recreate_octant_data();
|
||||
|
||||
struct BakeLight {
|
||||
RS::LightType type = RS::LightType::LIGHT_DIRECTIONAL;
|
||||
Vector3 pos;
|
||||
Vector3 dir;
|
||||
float param[RS::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;
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_3D_DISABLED
|
||||
void _update_physics_bodies_collision_properties();
|
||||
void _update_physics_bodies_characteristics();
|
||||
#endif // PHYSICS_3D_DISABLED
|
||||
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);
|
||||
#if defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
|
||||
void _update_octant_navigation_debug_edge_connections_mesh(const OctantKey &p_key);
|
||||
void _navigation_map_changed(RID p_map);
|
||||
void _update_navigation_debug_edge_connections();
|
||||
#endif // defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
|
||||
bool awaiting_update = false;
|
||||
|
||||
void _queue_octants_dirty();
|
||||
void _update_octants_callback();
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
void resource_changed(const Ref<Resource> &p_res);
|
||||
#endif
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
#ifndef PHYSICS_3D_DISABLED
|
||||
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_value(int p_layer_number, bool p_value);
|
||||
bool get_collision_layer_value(int p_layer_number) const;
|
||||
|
||||
void set_collision_mask_value(int p_layer_number, bool p_value);
|
||||
bool get_collision_mask_value(int p_layer_number) const;
|
||||
|
||||
void set_collision_priority(real_t p_priority);
|
||||
real_t get_collision_priority() const;
|
||||
|
||||
void set_physics_material(Ref<PhysicsMaterial> p_material);
|
||||
Ref<PhysicsMaterial> get_physics_material() const;
|
||||
|
||||
Array get_collision_shapes() const;
|
||||
#endif // PHYSICS_3D_DISABLED
|
||||
|
||||
void set_bake_navigation(bool p_bake_navigation);
|
||||
bool is_baking_navigation();
|
||||
|
||||
#ifndef NAVIGATION_3D_DISABLED
|
||||
void set_navigation_map(RID p_navigation_map);
|
||||
RID get_navigation_map() const;
|
||||
#endif // NAVIGATION_3D_DISABLED
|
||||
|
||||
void set_mesh_library(const Ref<MeshLibrary> &p_mesh_library);
|
||||
Ref<MeshLibrary> get_mesh_library() 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(const Vector3i &p_position, int p_item, int p_rot = 0);
|
||||
int get_cell_item(const Vector3i &p_position) const;
|
||||
int get_cell_item_orientation(const Vector3i &p_position) const;
|
||||
Basis get_cell_item_basis(const Vector3i &p_position) const;
|
||||
Basis get_basis_with_orthogonal_index(int p_index) const;
|
||||
int get_orthogonal_index_from_basis(const Basis &p_basis) const;
|
||||
|
||||
Vector3i local_to_map(const Vector3 &p_local_position) const;
|
||||
Vector3 map_to_local(const Vector3i &p_map_position) const;
|
||||
|
||||
void set_cell_scale(float p_scale);
|
||||
float get_cell_scale() const;
|
||||
|
||||
TypedArray<Vector3i> get_used_cells() const;
|
||||
TypedArray<Vector3i> 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);
|
||||
|
||||
#ifndef NAVIGATION_3D_DISABLED
|
||||
private:
|
||||
static Callable _navmesh_source_geometry_parsing_callback;
|
||||
static RID _navmesh_source_geometry_parser;
|
||||
#endif // NAVIGATION_3D_DISABLED
|
||||
|
||||
public:
|
||||
#ifndef NAVIGATION_3D_DISABLED
|
||||
static void navmesh_parse_init();
|
||||
static void navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, Node *p_node);
|
||||
#endif // NAVIGATION_3D_DISABLED
|
||||
|
||||
GridMap();
|
||||
~GridMap();
|
||||
};
|
1
modules/gridmap/icons/GridMap.svg
Normal file
1
modules/gridmap/icons/GridMap.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#fc7f7f" 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"/></svg>
|
After Width: | Height: | Size: 168 B |
64
modules/gridmap/register_types.cpp
Normal file
64
modules/gridmap/register_types.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/**************************************************************************/
|
||||
/* register_types.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* 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 _3D_DISABLED
|
||||
|
||||
#include "register_types.h"
|
||||
|
||||
#include "grid_map.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#include "editor/grid_map_editor_plugin.h"
|
||||
#endif
|
||||
|
||||
#include "core/object/class_db.h"
|
||||
|
||||
void initialize_gridmap_module(ModuleInitializationLevel p_level) {
|
||||
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
|
||||
GDREGISTER_CLASS(GridMap);
|
||||
#ifndef NAVIGATION_3D_DISABLED
|
||||
GridMap::navmesh_parse_init();
|
||||
#endif // NAVIGATION_3D_DISABLED
|
||||
}
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
|
||||
GDREGISTER_CLASS(GridMapEditorPlugin);
|
||||
EditorPlugins::add_by_type<GridMapEditorPlugin>();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void uninitialize_gridmap_module(ModuleInitializationLevel p_level) {
|
||||
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _3D_DISABLED
|
36
modules/gridmap/register_types.h
Normal file
36
modules/gridmap/register_types.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/**************************************************************************/
|
||||
/* register_types.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "modules/register_module_types.h"
|
||||
|
||||
void initialize_gridmap_module(ModuleInitializationLevel p_level);
|
||||
void uninitialize_gridmap_module(ModuleInitializationLevel p_level);
|
Reference in New Issue
Block a user