Skip to content

Commit cc7e7d7

Browse files
committed
Merge pull request godotengine#119319 from YeldhamDev/meshlib_categories
Add categories to `MeshLibrary`
2 parents 4250d35 + 1e27c21 commit cc7e7d7

6 files changed

Lines changed: 318 additions & 87 deletions

File tree

doc/classes/MeshLibrary.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
Returns the first item with the given name, or [code]-1[/code] if no item is found.
3333
</description>
3434
</method>
35+
<method name="get_item_category" qualifiers="const">
36+
<return type="StringName" />
37+
<param index="0" name="id" type="int" />
38+
<description>
39+
Returns the category for a specific item [param id]. See also [method set_item_category].
40+
</description>
41+
</method>
3542
<method name="get_item_count" qualifiers="const">
3643
<return type="int" />
3744
<description>
@@ -121,6 +128,14 @@
121128
Removes the item.
122129
</description>
123130
</method>
131+
<method name="set_item_category">
132+
<return type="void" />
133+
<param index="0" name="id" type="int" />
134+
<param index="1" name="category" type="StringName" />
135+
<description>
136+
Sets the [param category] for a specific item [param id] for organization in the [GridMap] editor. A category can include [code]/[/code] as a delimiter to create sub categories.
137+
</description>
138+
</method>
124139
<method name="set_item_mesh">
125140
<return type="void" />
126141
<param index="0" name="id" type="int" />

editor/scene/3d/mesh_library_editor_plugin.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ bool MeshLibraryEditor::MeshLibraryItem::_set(const StringName &p_name, const Va
6464

6565
if (p_name == "name") {
6666
mesh_library->set_item_name(mesh_id, p_value);
67+
} else if (p_name == "category") {
68+
mesh_library->set_item_category(mesh_id, p_value);
6769
} else if (p_name == "mesh") {
6870
mesh_library->set_item_mesh(mesh_id, p_value);
6971
} else if (p_name == "mesh_transform") {
@@ -112,6 +114,8 @@ bool MeshLibraryEditor::MeshLibraryItem::_get(const StringName &p_name, Variant
112114

113115
if (p_name == "name") {
114116
r_ret = mesh_library->get_item_name(mesh_id);
117+
} else if (p_name == "category") {
118+
r_ret = mesh_library->get_item_category(mesh_id);
115119
} else if (p_name == "mesh") {
116120
r_ret = mesh_library->get_item_mesh(mesh_id);
117121
} else if (p_name == "mesh_transform") {
@@ -143,6 +147,7 @@ void MeshLibraryEditor::MeshLibraryItem::_get_property_list(List<PropertyInfo> *
143147
}
144148

145149
p_list->push_back(PropertyInfo(Variant::STRING, PNAME("name")));
150+
p_list->push_back(PropertyInfo(Variant::STRING, PNAME("category")));
146151
p_list->push_back(PropertyInfo(Variant::OBJECT, PNAME("mesh"), PROPERTY_HINT_RESOURCE_TYPE, Mesh::get_class_static()));
147152
p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, PNAME("mesh_transform"), PROPERTY_HINT_NONE, "suffix:m"));
148153
p_list->push_back(PropertyInfo(Variant::INT, PNAME("mesh_cast_shadow"), PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only"));
@@ -739,6 +744,7 @@ MeshLibraryEditor::MeshLibraryEditor() {
739744
item_split->add_child(inspector);
740745

741746
inspector->add_custom_property_description("MeshLibraryItem", "name", TTRC("The item's name, shown in the editor. It can also be used to look up the item later using [method MeshLibrary.find_item_by_name]."));
747+
inspector->add_custom_property_description("MeshLibraryItem", "category", TTRC("The item's category, used to organize meshes in the [GridMap] editor. A category can include [code]/[/code] as a delimiter to create sub categories."));
742748
inspector->add_custom_property_description("MeshLibraryItem", "mesh", TTRC("The item's mesh. Used by other parts of the engine (e.g. [GridMap], which displays them in a 3D tile)."));
743749
inspector->add_custom_property_description("MeshLibraryItem", "mesh_transform", TTRC("The transform to apply to the item's mesh."));
744750
inspector->add_custom_property_description("MeshLibraryItem", "mesh_cast_shadow", TTRC("The shadow casting mode used by the item's mesh. See [enum RenderingServer.ShadowCastingSetting]."));

0 commit comments

Comments
 (0)