mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-04-08 04:51:49 +02:00
Now props added to TerrainWorld can also have a name. The prop bake editor tool uses it to save and restore node names.
This commit is contained in:
parent
474ab893d6
commit
7e52eb6b43
@ -1430,6 +1430,7 @@ void TerrainWorldEditor::bake_props(const ObjectID p_world) {
|
||||
|
||||
Ref<PropData> pd = prop_instance->get_prop_data();
|
||||
Transform t = prop_instance->get_global_transform();
|
||||
String name = prop_instance->get_name();
|
||||
|
||||
prop_instance->queue_delete();
|
||||
|
||||
@ -1439,7 +1440,7 @@ void TerrainWorldEditor::bake_props(const ObjectID p_world) {
|
||||
continue;
|
||||
}
|
||||
|
||||
world->prop_add(t, pd, false);
|
||||
world->prop_add(t, pd, false, true, name);
|
||||
}
|
||||
|
||||
String results = "Baked " + String::num_int64(baked_props_count) + " direct child props into TerrainWorld. ";
|
||||
@ -1466,11 +1467,15 @@ void TerrainWorldEditor::un_bake_props(const ObjectID p_world) {
|
||||
|
||||
Ref<PropData> pd = chunk->prop_get(j);
|
||||
Transform t = chunk->prop_get_transform(j);
|
||||
String name = chunk->prop_get_name(j);
|
||||
|
||||
PropInstanceMerger *prop_instance = memnew(PropInstanceMerger);
|
||||
|
||||
prop_instance->set_global_transform(t);
|
||||
prop_instance->set_prop_data(pd);
|
||||
if (!name.empty()) {
|
||||
prop_instance->set_name(name);
|
||||
}
|
||||
|
||||
world->add_child(prop_instance);
|
||||
prop_instance->set_owner(_editor->get_edited_scene());
|
||||
|
@ -1192,10 +1192,11 @@ void TerrainChunk::clear_baked_lights() {
|
||||
}
|
||||
|
||||
#ifdef MODULE_PROPS_ENABLED
|
||||
void TerrainChunk::prop_add(const Transform &transform, const Ref<PropData> &prop, const bool p_original) {
|
||||
void TerrainChunk::prop_add(const Transform &transform, const Ref<PropData> &prop, const bool p_original, const String &p_name) {
|
||||
ERR_FAIL_COND(!prop.is_valid());
|
||||
|
||||
PropDataStore s;
|
||||
s.name = p_name;
|
||||
s.original = p_original;
|
||||
s.transform = transform;
|
||||
s.prop = prop;
|
||||
@ -1244,6 +1245,19 @@ void TerrainChunk::prop_set_is_original(const int index, const bool p_original)
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
String TerrainChunk::prop_get_name(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, _props.size(), String());
|
||||
|
||||
return _props.get(index).name;
|
||||
}
|
||||
void TerrainChunk::prop_set_name(const int index, const String &p_name) {
|
||||
ERR_FAIL_INDEX(index, _props.size());
|
||||
|
||||
_props.write[index].name = p_name;
|
||||
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
int TerrainChunk::prop_get_count() const {
|
||||
return _props.size();
|
||||
}
|
||||
@ -2210,7 +2224,7 @@ void TerrainChunk::_bind_methods() {
|
||||
//Props
|
||||
|
||||
#ifdef MODULE_PROPS_ENABLED
|
||||
ClassDB::bind_method(D_METHOD("prop_add", "transform", "prop", "original"), &TerrainChunk::prop_add, DEFVAL(true));
|
||||
ClassDB::bind_method(D_METHOD("prop_add", "transform", "prop", "original", "name"), &TerrainChunk::prop_add, DEFVAL(true), DEFVAL(String()));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("prop_get", "index"), &TerrainChunk::prop_get);
|
||||
ClassDB::bind_method(D_METHOD("prop_set", "index", "prop"), &TerrainChunk::prop_set);
|
||||
@ -2221,6 +2235,9 @@ void TerrainChunk::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("prop_get_is_original", "index"), &TerrainChunk::prop_get_is_original);
|
||||
ClassDB::bind_method(D_METHOD("prop_set_is_original", "index", "original"), &TerrainChunk::prop_set_is_original);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("prop_get_name", "index"), &TerrainChunk::prop_get_name);
|
||||
ClassDB::bind_method(D_METHOD("prop_set_name", "index", "name"), &TerrainChunk::prop_set_name);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("prop_get_count"), &TerrainChunk::prop_get_count);
|
||||
ClassDB::bind_method(D_METHOD("prop_remove", "index"), &TerrainChunk::prop_remove);
|
||||
ClassDB::bind_method(D_METHOD("props_clear"), &TerrainChunk::props_clear);
|
||||
|
@ -289,7 +289,7 @@ public:
|
||||
void clear_baked_lights();
|
||||
|
||||
#ifdef MODULE_PROPS_ENABLED
|
||||
void prop_add(const Transform &transform, const Ref<PropData> &prop, const bool p_original = true);
|
||||
void prop_add(const Transform &transform, const Ref<PropData> &prop, const bool p_original = true, const String &p_name = String());
|
||||
|
||||
Ref<PropData> prop_get(const int index);
|
||||
void prop_set(const int index, const Ref<PropData> &p_prop);
|
||||
@ -300,6 +300,9 @@ public:
|
||||
bool prop_get_is_original(const int index);
|
||||
void prop_set_is_original(const int index, const bool p_original);
|
||||
|
||||
String prop_get_name(const int index);
|
||||
void prop_set_name(const int index, const String &p_name);
|
||||
|
||||
int prop_get_count() const;
|
||||
void prop_remove(const int index);
|
||||
void props_clear();
|
||||
@ -400,6 +403,7 @@ protected:
|
||||
|
||||
#ifdef MODULE_PROPS_ENABLED
|
||||
struct PropDataStore {
|
||||
String name;
|
||||
bool original;
|
||||
Transform transform;
|
||||
Ref<PropData> prop;
|
||||
|
@ -624,7 +624,7 @@ void TerrainWorld::scene_add(const Ref<PackedScene> &p_scene, const Transform &p
|
||||
}
|
||||
|
||||
#ifdef MODULE_PROPS_ENABLED
|
||||
void TerrainWorld::prop_add(Transform transform, const Ref<PropData> &prop, const bool apply_voxel_scale, const bool p_original) {
|
||||
void TerrainWorld::prop_add(Transform transform, const Ref<PropData> &prop, const bool apply_voxel_scale, const bool p_original, const String &p_name) {
|
||||
ERR_FAIL_COND(!prop.is_valid());
|
||||
|
||||
if (apply_voxel_scale) {
|
||||
@ -635,7 +635,7 @@ void TerrainWorld::prop_add(Transform transform, const Ref<PropData> &prop, cons
|
||||
wp = transform.xform(wp);
|
||||
Ref<TerrainChunk> chunk = get_or_create_chunk_at_world_position(wp);
|
||||
|
||||
chunk->prop_add(transform, prop, p_original);
|
||||
chunk->prop_add(transform, prop, p_original, p_name);
|
||||
chunk->build();
|
||||
|
||||
int count = prop->get_prop_count();
|
||||
@ -1622,7 +1622,7 @@ void TerrainWorld::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("scene_add", "scene", "transform", "node", "original"), &TerrainWorld::scene_add, DEFVAL(Transform()), DEFVAL(Variant()), DEFVAL(true));
|
||||
|
||||
#ifdef MODULE_PROPS_ENABLED
|
||||
ClassDB::bind_method(D_METHOD("prop_add", "transform", "prop", "apply_voxel_scale", "original"), &TerrainWorld::prop_add, DEFVAL(true), DEFVAL(true));
|
||||
ClassDB::bind_method(D_METHOD("prop_add", "transform", "prop", "apply_voxel_scale", "original", "name"), &TerrainWorld::prop_add, DEFVAL(true), DEFVAL(true), DEFVAL(String()));
|
||||
#endif
|
||||
|
||||
//Lights
|
||||
|
@ -178,7 +178,7 @@ public:
|
||||
void scene_add(const Ref<PackedScene> &p_scene, const Transform &p_transform = Transform(), const Node *p_node = NULL, const bool p_original = true);
|
||||
|
||||
#ifdef MODULE_PROPS_ENABLED
|
||||
void prop_add(Transform transform, const Ref<PropData> &prop, const bool apply_voxel_scale = true, const bool p_original = true);
|
||||
void prop_add(Transform transform, const Ref<PropData> &prop, const bool apply_voxel_scale = true, const bool p_original = true, const String &p_name = String());
|
||||
#endif
|
||||
|
||||
//Lights
|
||||
|
Loading…
Reference in New Issue
Block a user