mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-03-21 03:52:27 +01:00
Added scene storage api to TerrainChunks.
Also mass replaced the typo "tarnsform" to "transform", and fixed a parameter name in a TerrainChunk binding.
This commit is contained in:
parent
418bac4209
commit
39eeba0efd
@ -24,7 +24,7 @@
|
|||||||
</method>
|
</method>
|
||||||
<method name="_prop_preprocess" qualifiers="virtual">
|
<method name="_prop_preprocess" qualifiers="virtual">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<argument index="0" name="tarnsform" type="Transform" />
|
<argument index="0" name="transform" type="Transform" />
|
||||||
<argument index="1" name="prop_data" type="PropData" />
|
<argument index="1" name="prop_data" type="PropData" />
|
||||||
<description>
|
<description>
|
||||||
</description>
|
</description>
|
||||||
@ -46,7 +46,7 @@
|
|||||||
</method>
|
</method>
|
||||||
<method name="prop_preprocess">
|
<method name="prop_preprocess">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<argument index="0" name="tarnsform" type="Transform" />
|
<argument index="0" name="transform" type="Transform" />
|
||||||
<argument index="1" name="prop" type="PropData" />
|
<argument index="1" name="prop" type="PropData" />
|
||||||
<description>
|
<description>
|
||||||
</description>
|
</description>
|
||||||
|
@ -342,11 +342,11 @@ void PropInstance::_bind_methods() {
|
|||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
||||||
|
|
||||||
BIND_VMETHOD(MethodInfo("_prop_preprocess",
|
BIND_VMETHOD(MethodInfo("_prop_preprocess",
|
||||||
PropertyInfo(Variant::TRANSFORM, "tarnsform"),
|
PropertyInfo(Variant::TRANSFORM, "transform"),
|
||||||
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData")));
|
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData")));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("prop_preprocess", "tarnsform", "prop"), &PropInstance::prop_preprocess);
|
ClassDB::bind_method(D_METHOD("prop_preprocess", "transform", "prop"), &PropInstance::prop_preprocess);
|
||||||
ClassDB::bind_method(D_METHOD("_prop_preprocess", "tarnsform", "prop"), &PropInstance::_prop_preprocess);
|
ClassDB::bind_method(D_METHOD("_prop_preprocess", "transform", "prop"), &PropInstance::_prop_preprocess);
|
||||||
|
|
||||||
//---
|
//---
|
||||||
BIND_VMETHOD(MethodInfo("_init_materials"));
|
BIND_VMETHOD(MethodInfo("_init_materials"));
|
||||||
|
@ -69,8 +69,8 @@ public:
|
|||||||
virtual void _build();
|
virtual void _build();
|
||||||
virtual void _build_finished();
|
virtual void _build_finished();
|
||||||
|
|
||||||
void prop_preprocess(Transform tarnsform, const Ref<PropData> &prop);
|
void prop_preprocess(Transform transform, const Ref<PropData> &prop);
|
||||||
virtual void _prop_preprocess(Transform tarnsform, const Ref<PropData> &prop);
|
virtual void _prop_preprocess(Transform transform, const Ref<PropData> &prop);
|
||||||
|
|
||||||
PropInstance();
|
PropInstance();
|
||||||
~PropInstance();
|
~PropInstance();
|
||||||
|
@ -122,7 +122,7 @@ public:
|
|||||||
virtual void _build();
|
virtual void _build();
|
||||||
virtual void _build_finished();
|
virtual void _build_finished();
|
||||||
|
|
||||||
void _prop_preprocess(Transform tarnsform, const Ref<PropData> &prop);
|
void _prop_preprocess(Transform transform, const Ref<PropData> &prop);
|
||||||
|
|
||||||
void collision_layer_changed();
|
void collision_layer_changed();
|
||||||
void collision_mask_changed();
|
void collision_mask_changed();
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
</method>
|
</method>
|
||||||
<method name="_prop_preprocess" qualifiers="virtual">
|
<method name="_prop_preprocess" qualifiers="virtual">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<argument index="0" name="tarnsform" type="Transform" />
|
<argument index="0" name="transform" type="Transform" />
|
||||||
<argument index="1" name="prop_data" type="Prop2DData" />
|
<argument index="1" name="prop_data" type="Prop2DData" />
|
||||||
<description>
|
<description>
|
||||||
</description>
|
</description>
|
||||||
@ -46,7 +46,7 @@
|
|||||||
</method>
|
</method>
|
||||||
<method name="prop_preprocess">
|
<method name="prop_preprocess">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<argument index="0" name="tarnsform" type="Transform2D" />
|
<argument index="0" name="transform" type="Transform2D" />
|
||||||
<argument index="1" name="prop" type="Prop2DData" />
|
<argument index="1" name="prop" type="Prop2DData" />
|
||||||
<description>
|
<description>
|
||||||
</description>
|
</description>
|
||||||
|
@ -295,11 +295,11 @@ void Prop2DInstance::_bind_methods() {
|
|||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
||||||
|
|
||||||
BIND_VMETHOD(MethodInfo("_prop_preprocess",
|
BIND_VMETHOD(MethodInfo("_prop_preprocess",
|
||||||
PropertyInfo(Variant::TRANSFORM, "tarnsform"),
|
PropertyInfo(Variant::TRANSFORM, "transform"),
|
||||||
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DData")));
|
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DData")));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("prop_preprocess", "tarnsform", "prop"), &Prop2DInstance::prop_preprocess);
|
ClassDB::bind_method(D_METHOD("prop_preprocess", "transform", "prop"), &Prop2DInstance::prop_preprocess);
|
||||||
ClassDB::bind_method(D_METHOD("_prop_preprocess", "tarnsform", "prop"), &Prop2DInstance::_prop_preprocess);
|
ClassDB::bind_method(D_METHOD("_prop_preprocess", "transform", "prop"), &Prop2DInstance::_prop_preprocess);
|
||||||
|
|
||||||
//---
|
//---
|
||||||
BIND_VMETHOD(MethodInfo("_init_materials"));
|
BIND_VMETHOD(MethodInfo("_init_materials"));
|
||||||
|
@ -66,8 +66,8 @@ public:
|
|||||||
virtual void _build();
|
virtual void _build();
|
||||||
virtual void _build_finished();
|
virtual void _build_finished();
|
||||||
|
|
||||||
void prop_preprocess(Transform2D tarnsform, const Ref<Prop2DData> &prop);
|
void prop_preprocess(Transform2D transform, const Ref<Prop2DData> &prop);
|
||||||
virtual void _prop_preprocess(Transform2D tarnsform, const Ref<Prop2DData> &prop);
|
virtual void _prop_preprocess(Transform2D transform, const Ref<Prop2DData> &prop);
|
||||||
|
|
||||||
Prop2DInstance();
|
Prop2DInstance();
|
||||||
~Prop2DInstance();
|
~Prop2DInstance();
|
||||||
|
@ -95,7 +95,7 @@ public:
|
|||||||
virtual void _build();
|
virtual void _build();
|
||||||
virtual void _build_finished();
|
virtual void _build_finished();
|
||||||
|
|
||||||
void _prop_preprocess(Transform2D tarnsform, const Ref<Prop2DData> &prop);
|
void _prop_preprocess(Transform2D transform, const Ref<Prop2DData> &prop);
|
||||||
|
|
||||||
void collision_layer_changed();
|
void collision_layer_changed();
|
||||||
void collision_mask_changed();
|
void collision_mask_changed();
|
||||||
|
@ -143,7 +143,7 @@ void TerrainPropJob::phase_physics_process() {
|
|||||||
#ifdef MODULE_PROPS_ENABLED
|
#ifdef MODULE_PROPS_ENABLED
|
||||||
for (int i = 0; i < chunk->prop_get_count(); ++i) {
|
for (int i = 0; i < chunk->prop_get_count(); ++i) {
|
||||||
Ref<PropData> prop = chunk->prop_get(i);
|
Ref<PropData> prop = chunk->prop_get(i);
|
||||||
Transform prop_transform = chunk->prop_get_tarnsform(i);
|
Transform prop_transform = chunk->prop_get_transform(i);
|
||||||
Transform chunk_prop_local_tform = prop_transform;
|
Transform chunk_prop_local_tform = prop_transform;
|
||||||
chunk_prop_local_tform.origin = chunk->to_local(chunk_prop_local_tform.origin);
|
chunk_prop_local_tform.origin = chunk->to_local(chunk_prop_local_tform.origin);
|
||||||
|
|
||||||
|
@ -869,6 +869,97 @@ void TerrainChunk::voxel_structures_set(const Vector<Variant> &structures) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Scenes
|
||||||
|
|
||||||
|
void TerrainChunk::scene_add(const Ref<PackedScene> &p_scene, const Transform &p_transform, const bool p_original) {
|
||||||
|
ERR_FAIL_COND(!p_scene.is_valid());
|
||||||
|
|
||||||
|
SceneDataStore s;
|
||||||
|
s.original = p_original;
|
||||||
|
s.transform = p_transform;
|
||||||
|
s.scene = p_scene;
|
||||||
|
|
||||||
|
_scenes.push_back(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<PackedScene> TerrainChunk::scene_get(int index) {
|
||||||
|
ERR_FAIL_INDEX_V(index, _scenes.size(), Ref<PackedScene>());
|
||||||
|
|
||||||
|
return _scenes.get(index).scene;
|
||||||
|
}
|
||||||
|
void TerrainChunk::scene_set(const int index, const Ref<PackedScene> &p_scene) {
|
||||||
|
ERR_FAIL_INDEX(index, _scenes.size());
|
||||||
|
|
||||||
|
_scenes.write[index].scene = p_scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
Transform TerrainChunk::scene_get_transform(const int index) {
|
||||||
|
ERR_FAIL_INDEX_V(index, _scenes.size(), Transform());
|
||||||
|
|
||||||
|
return _scenes.get(index).transform;
|
||||||
|
}
|
||||||
|
void TerrainChunk::scene_set_transform(const int index, const Transform &p_transform) {
|
||||||
|
ERR_FAIL_INDEX(index, _scenes.size());
|
||||||
|
|
||||||
|
_scenes.write[index].transform = p_transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TerrainChunk::scene_get_is_original(const int index) {
|
||||||
|
ERR_FAIL_INDEX_V(index, _scenes.size(), false);
|
||||||
|
|
||||||
|
return _scenes.get(index).original;
|
||||||
|
}
|
||||||
|
void TerrainChunk::scene_set_is_original(const int index, const bool p_original) {
|
||||||
|
ERR_FAIL_INDEX(index, _scenes.size());
|
||||||
|
|
||||||
|
_scenes.write[index].original = p_original;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TerrainChunk::scene_get_count() const {
|
||||||
|
return _scenes.size();
|
||||||
|
}
|
||||||
|
void TerrainChunk::scene_remove(const int index) {
|
||||||
|
ERR_FAIL_INDEX(index, _scenes.size());
|
||||||
|
|
||||||
|
_scenes.remove(index);
|
||||||
|
}
|
||||||
|
void TerrainChunk::scenes_clear() {
|
||||||
|
_scenes.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
Array TerrainChunk::scenes_get() {
|
||||||
|
Array ret;
|
||||||
|
|
||||||
|
for (int i = 0; i < _scenes.size(); i++) {
|
||||||
|
Array prop_data;
|
||||||
|
|
||||||
|
prop_data.push_back(_scenes[i].original);
|
||||||
|
prop_data.push_back(_scenes[i].transform);
|
||||||
|
prop_data.push_back(_scenes[i].scene.get_ref_ptr());
|
||||||
|
|
||||||
|
ret.push_back(prop_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
void TerrainChunk::scenes_set(const Array &p_scenes) {
|
||||||
|
props_clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < p_scenes.size(); ++i) {
|
||||||
|
Array scene_data = p_scenes[i];
|
||||||
|
|
||||||
|
ERR_CONTINUE(scene_data.size() != 3);
|
||||||
|
|
||||||
|
bool original = scene_data[0];
|
||||||
|
Transform transform = scene_data[1];
|
||||||
|
Ref<PackedScene> scene = Ref<PackedScene>(scene_data[2]);
|
||||||
|
|
||||||
|
scene_add(scene, transform, original);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Meshing
|
||||||
|
|
||||||
void TerrainChunk::build() {
|
void TerrainChunk::build() {
|
||||||
ERR_FAIL_COND(!ObjectDB::instance_validate(get_voxel_world()));
|
ERR_FAIL_COND(!ObjectDB::instance_validate(get_voxel_world()));
|
||||||
ERR_FAIL_COND(!get_voxel_world()->is_inside_tree());
|
ERR_FAIL_COND(!get_voxel_world()->is_inside_tree());
|
||||||
@ -956,12 +1047,12 @@ void TerrainChunk::clear_baked_lights() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_PROPS_ENABLED
|
#ifdef MODULE_PROPS_ENABLED
|
||||||
void TerrainChunk::prop_add(const Transform &tarnsform, const Ref<PropData> &prop, const bool p_original) {
|
void TerrainChunk::prop_add(const Transform &transform, const Ref<PropData> &prop, const bool p_original) {
|
||||||
ERR_FAIL_COND(!prop.is_valid());
|
ERR_FAIL_COND(!prop.is_valid());
|
||||||
|
|
||||||
PropDataStore s;
|
PropDataStore s;
|
||||||
s.original = p_original;
|
s.original = p_original;
|
||||||
s.transform = tarnsform;
|
s.transform = transform;
|
||||||
s.prop = prop;
|
s.prop = prop;
|
||||||
|
|
||||||
_props.push_back(s);
|
_props.push_back(s);
|
||||||
@ -978,12 +1069,12 @@ void TerrainChunk::prop_set(const int index, const Ref<PropData> &p_prop) {
|
|||||||
_props.write[index].prop = p_prop;
|
_props.write[index].prop = p_prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform TerrainChunk::prop_get_tarnsform(const int index) {
|
Transform TerrainChunk::prop_get_transform(const int index) {
|
||||||
ERR_FAIL_INDEX_V(index, _props.size(), Transform());
|
ERR_FAIL_INDEX_V(index, _props.size(), Transform());
|
||||||
|
|
||||||
return _props.get(index).transform;
|
return _props.get(index).transform;
|
||||||
}
|
}
|
||||||
void TerrainChunk::prop_set_tarnsform(const int index, const Transform &p_transform) {
|
void TerrainChunk::prop_set_transform(const int index, const Transform &p_transform) {
|
||||||
ERR_FAIL_INDEX(index, _props.size());
|
ERR_FAIL_INDEX(index, _props.size());
|
||||||
|
|
||||||
_props.write[index].transform = p_transform;
|
_props.write[index].transform = p_transform;
|
||||||
@ -1884,16 +1975,37 @@ void TerrainChunk::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("voxel_structures_set"), &TerrainChunk::voxel_structures_set);
|
ClassDB::bind_method(D_METHOD("voxel_structures_set"), &TerrainChunk::voxel_structures_set);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_structures", PROPERTY_HINT_NONE, "23/20:TerrainStructure", PROPERTY_USAGE_DEFAULT, "TerrainStructure"), "voxel_structures_set", "voxel_structures_get");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_structures", PROPERTY_HINT_NONE, "23/20:TerrainStructure", PROPERTY_USAGE_DEFAULT, "TerrainStructure"), "voxel_structures_set", "voxel_structures_get");
|
||||||
|
|
||||||
//Meshes
|
//Scenes
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("scene_add", "scene", "transform", "original"), &TerrainChunk::scene_add, DEFVAL(Transform()), DEFVAL(true));
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("scene_get", "index"), &TerrainChunk::scene_get);
|
||||||
|
ClassDB::bind_method(D_METHOD("scene_set", "index", "scene"), &TerrainChunk::scene_set);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("scene_get_transform", "index"), &TerrainChunk::scene_get_transform);
|
||||||
|
ClassDB::bind_method(D_METHOD("scene_set_transform", "index", "transform"), &TerrainChunk::scene_set_transform);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("scene_get_is_original", "index"), &TerrainChunk::scene_get_is_original);
|
||||||
|
ClassDB::bind_method(D_METHOD("scene_set_is_original", "index", "original"), &TerrainChunk::scene_set_is_original);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("scene_get_count"), &TerrainChunk::scene_get_count);
|
||||||
|
ClassDB::bind_method(D_METHOD("scene_remove", "index"), &TerrainChunk::scene_remove);
|
||||||
|
ClassDB::bind_method(D_METHOD("scenes_clear"), &TerrainChunk::scenes_clear);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("scenes_get"), &TerrainChunk::scenes_get);
|
||||||
|
ClassDB::bind_method(D_METHOD("scenes_set"), &TerrainChunk::scenes_set);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "scenes"), "scenes_set", "scenes_get");
|
||||||
|
|
||||||
|
//Props
|
||||||
|
|
||||||
#ifdef MODULE_PROPS_ENABLED
|
#ifdef MODULE_PROPS_ENABLED
|
||||||
ClassDB::bind_method(D_METHOD("prop_add", "prop", "original"), &TerrainChunk::prop_add, DEFVAL(true));
|
ClassDB::bind_method(D_METHOD("prop_add", "transform", "prop", "original"), &TerrainChunk::prop_add, DEFVAL(true));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("prop_get", "index"), &TerrainChunk::prop_get);
|
ClassDB::bind_method(D_METHOD("prop_get", "index"), &TerrainChunk::prop_get);
|
||||||
ClassDB::bind_method(D_METHOD("prop_set", "index", "prop"), &TerrainChunk::prop_set);
|
ClassDB::bind_method(D_METHOD("prop_set", "index", "prop"), &TerrainChunk::prop_set);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("prop_get_tarnsform", "index"), &TerrainChunk::prop_get_tarnsform);
|
ClassDB::bind_method(D_METHOD("prop_get_transform", "index"), &TerrainChunk::prop_get_transform);
|
||||||
ClassDB::bind_method(D_METHOD("prop_set_tarnsform", "index", "transform"), &TerrainChunk::prop_set_tarnsform);
|
ClassDB::bind_method(D_METHOD("prop_set_transform", "index", "transform"), &TerrainChunk::prop_set_transform);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("prop_get_is_original", "index"), &TerrainChunk::prop_get_is_original);
|
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_set_is_original", "index", "original"), &TerrainChunk::prop_set_is_original);
|
||||||
@ -1907,6 +2019,8 @@ void TerrainChunk::_bind_methods() {
|
|||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "props"), "props_set", "props_get");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "props"), "props_set", "props_get");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//Meshes
|
||||||
|
|
||||||
#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED
|
#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED
|
||||||
ClassDB::bind_method(D_METHOD("mesh_data_resource_addv", "local_data_pos", "mesh", "texture", "color", "apply_voxel_scale"), &TerrainChunk::mesh_data_resource_addv, DEFVAL(Ref<Texture>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true));
|
ClassDB::bind_method(D_METHOD("mesh_data_resource_addv", "local_data_pos", "mesh", "texture", "color", "apply_voxel_scale"), &TerrainChunk::mesh_data_resource_addv, DEFVAL(Ref<Texture>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true));
|
||||||
ClassDB::bind_method(D_METHOD("mesh_data_resource_add", "local_transform", "mesh", "texture", "color", "apply_voxel_scale"), &TerrainChunk::mesh_data_resource_add, DEFVAL(Ref<Texture>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true));
|
ClassDB::bind_method(D_METHOD("mesh_data_resource_add", "local_transform", "mesh", "texture", "color", "apply_voxel_scale"), &TerrainChunk::mesh_data_resource_add, DEFVAL(Ref<Texture>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true));
|
||||||
|
@ -247,6 +247,25 @@ public:
|
|||||||
Vector<Variant> voxel_structures_get();
|
Vector<Variant> voxel_structures_get();
|
||||||
void voxel_structures_set(const Vector<Variant> &structures);
|
void voxel_structures_set(const Vector<Variant> &structures);
|
||||||
|
|
||||||
|
//Scenes
|
||||||
|
void scene_add(const Ref<PackedScene> &p_scene, const Transform &p_transform = Transform(), const bool p_original = true);
|
||||||
|
|
||||||
|
Ref<PackedScene> scene_get(const int index);
|
||||||
|
void scene_set(const int index, const Ref<PackedScene> &p_scene);
|
||||||
|
|
||||||
|
Transform scene_get_transform(const int index);
|
||||||
|
void scene_set_transform(const int index, const Transform &p_transform);
|
||||||
|
|
||||||
|
bool scene_get_is_original(const int index);
|
||||||
|
void scene_set_is_original(const int index, const bool p_original);
|
||||||
|
|
||||||
|
int scene_get_count() const;
|
||||||
|
void scene_remove(const int index);
|
||||||
|
void scenes_clear();
|
||||||
|
|
||||||
|
Array scenes_get();
|
||||||
|
void scenes_set(const Array &p_scenes);
|
||||||
|
|
||||||
//Meshing
|
//Meshing
|
||||||
void build();
|
void build();
|
||||||
void build_immediate();
|
void build_immediate();
|
||||||
@ -263,13 +282,13 @@ public:
|
|||||||
void clear_baked_lights();
|
void clear_baked_lights();
|
||||||
|
|
||||||
#ifdef MODULE_PROPS_ENABLED
|
#ifdef MODULE_PROPS_ENABLED
|
||||||
void prop_add(const Transform &tarnsform, const Ref<PropData> &prop, const bool p_original = true);
|
void prop_add(const Transform &transform, const Ref<PropData> &prop, const bool p_original = true);
|
||||||
|
|
||||||
Ref<PropData> prop_get(const int index);
|
Ref<PropData> prop_get(const int index);
|
||||||
void prop_set(const int index, const Ref<PropData> &p_prop);
|
void prop_set(const int index, const Ref<PropData> &p_prop);
|
||||||
|
|
||||||
Transform prop_get_tarnsform(const int index);
|
Transform prop_get_transform(const int index);
|
||||||
void prop_set_tarnsform(const int index, const Transform &p_transform);
|
void prop_set_transform(const int index, const Transform &p_transform);
|
||||||
|
|
||||||
bool prop_get_is_original(const int index);
|
bool prop_get_is_original(const int index);
|
||||||
void prop_set_is_original(const int index, const bool p_original);
|
void prop_set_is_original(const int index, const bool p_original);
|
||||||
@ -365,6 +384,12 @@ protected:
|
|||||||
virtual void _generation_physics_process(const float delta);
|
virtual void _generation_physics_process(const float delta);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
struct SceneDataStore {
|
||||||
|
bool original;
|
||||||
|
Transform transform;
|
||||||
|
Ref<PackedScene> scene;
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef MODULE_PROPS_ENABLED
|
#ifdef MODULE_PROPS_ENABLED
|
||||||
struct PropDataStore {
|
struct PropDataStore {
|
||||||
bool original;
|
bool original;
|
||||||
@ -456,6 +481,8 @@ protected:
|
|||||||
|
|
||||||
Vector<Ref<TerrainStructure>> _voxel_structures;
|
Vector<Ref<TerrainStructure>> _voxel_structures;
|
||||||
|
|
||||||
|
Vector<SceneDataStore> _scenes;
|
||||||
|
|
||||||
#ifdef MODULE_PROPS_ENABLED
|
#ifdef MODULE_PROPS_ENABLED
|
||||||
Vector<PropDataStore> _props;
|
Vector<PropDataStore> _props;
|
||||||
#endif
|
#endif
|
||||||
|
@ -753,11 +753,11 @@ void Terrain2DChunk::clear_baked_lights() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_PROPS_2D_ENABLED
|
#ifdef MODULE_PROPS_2D_ENABLED
|
||||||
void Terrain2DChunk::prop_add(const Transform2D &tarnsform, const Ref<Prop2DData> &prop) {
|
void Terrain2DChunk::prop_add(const Transform2D &transform, const Ref<Prop2DData> &prop) {
|
||||||
ERR_FAIL_COND(!prop.is_valid());
|
ERR_FAIL_COND(!prop.is_valid());
|
||||||
|
|
||||||
Prop2DDataStore s;
|
Prop2DDataStore s;
|
||||||
s.transform = tarnsform;
|
s.transform = transform;
|
||||||
s.prop = prop;
|
s.prop = prop;
|
||||||
|
|
||||||
_props.push_back(s);
|
_props.push_back(s);
|
||||||
@ -767,7 +767,7 @@ Ref<Prop2DData> Terrain2DChunk::prop_get(int index) {
|
|||||||
|
|
||||||
return _props.get(index).prop;
|
return _props.get(index).prop;
|
||||||
}
|
}
|
||||||
Transform2D Terrain2DChunk::prop_get_tarnsform(const int index) {
|
Transform2D Terrain2DChunk::prop_get_transform(const int index) {
|
||||||
ERR_FAIL_INDEX_V(index, _props.size(), Transform2D());
|
ERR_FAIL_INDEX_V(index, _props.size(), Transform2D());
|
||||||
|
|
||||||
return _props.get(index).transform;
|
return _props.get(index).transform;
|
||||||
|
@ -271,9 +271,9 @@ public:
|
|||||||
void clear_baked_lights();
|
void clear_baked_lights();
|
||||||
|
|
||||||
#ifdef MODULE_PROPS_2D_ENABLED
|
#ifdef MODULE_PROPS_2D_ENABLED
|
||||||
void prop_add(const Transform2D &tarnsform, const Ref<Prop2DData> &prop);
|
void prop_add(const Transform2D &transform, const Ref<Prop2DData> &prop);
|
||||||
Ref<Prop2DData> prop_get(const int index);
|
Ref<Prop2DData> prop_get(const int index);
|
||||||
Transform2D prop_get_tarnsform(const int index);
|
Transform2D prop_get_transform(const int index);
|
||||||
int prop_get_count() const;
|
int prop_get_count() const;
|
||||||
void prop_remove(const int index);
|
void prop_remove(const int index);
|
||||||
void props_clear();
|
void props_clear();
|
||||||
|
@ -144,7 +144,7 @@ void VoxelPropJob::phase_physics_process() {
|
|||||||
#ifdef MODULE_PROPS_ENABLED
|
#ifdef MODULE_PROPS_ENABLED
|
||||||
for (int i = 0; i < chunk->prop_get_count(); ++i) {
|
for (int i = 0; i < chunk->prop_get_count(); ++i) {
|
||||||
Ref<PropData> prop = chunk->prop_get(i);
|
Ref<PropData> prop = chunk->prop_get(i);
|
||||||
Transform prop_transform = chunk->prop_get_tarnsform(i);
|
Transform prop_transform = chunk->prop_get_transform(i);
|
||||||
Transform chunk_prop_local_tform = prop_transform;
|
Transform chunk_prop_local_tform = prop_transform;
|
||||||
chunk_prop_local_tform.origin = chunk->to_local(chunk_prop_local_tform.origin);
|
chunk_prop_local_tform.origin = chunk->to_local(chunk_prop_local_tform.origin);
|
||||||
|
|
||||||
|
@ -714,11 +714,11 @@ void VoxelChunk::clear_baked_lights() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_PROPS_ENABLED
|
#ifdef MODULE_PROPS_ENABLED
|
||||||
void VoxelChunk::prop_add(const Transform &tarnsform, const Ref<PropData> &prop) {
|
void VoxelChunk::prop_add(const Transform &transform, const Ref<PropData> &prop) {
|
||||||
ERR_FAIL_COND(!prop.is_valid());
|
ERR_FAIL_COND(!prop.is_valid());
|
||||||
|
|
||||||
PropDataStore s;
|
PropDataStore s;
|
||||||
s.transform = tarnsform;
|
s.transform = transform;
|
||||||
s.prop = prop;
|
s.prop = prop;
|
||||||
|
|
||||||
_props.push_back(s);
|
_props.push_back(s);
|
||||||
@ -728,7 +728,7 @@ Ref<PropData> VoxelChunk::prop_get(int index) {
|
|||||||
|
|
||||||
return _props.get(index).prop;
|
return _props.get(index).prop;
|
||||||
}
|
}
|
||||||
Transform VoxelChunk::prop_get_tarnsform(const int index) {
|
Transform VoxelChunk::prop_get_transform(const int index) {
|
||||||
ERR_FAIL_INDEX_V(index, _props.size(), Transform());
|
ERR_FAIL_INDEX_V(index, _props.size(), Transform());
|
||||||
|
|
||||||
return _props.get(index).transform;
|
return _props.get(index).transform;
|
||||||
|
@ -235,9 +235,9 @@ public:
|
|||||||
void clear_baked_lights();
|
void clear_baked_lights();
|
||||||
|
|
||||||
#ifdef MODULE_PROPS_ENABLED
|
#ifdef MODULE_PROPS_ENABLED
|
||||||
void prop_add(const Transform &tarnsform, const Ref<PropData> &prop);
|
void prop_add(const Transform &transform, const Ref<PropData> &prop);
|
||||||
Ref<PropData> prop_get(const int index);
|
Ref<PropData> prop_get(const int index);
|
||||||
Transform prop_get_tarnsform(const int index);
|
Transform prop_get_transform(const int index);
|
||||||
int prop_get_count() const;
|
int prop_get_count() const;
|
||||||
void prop_remove(const int index);
|
void prop_remove(const int index);
|
||||||
void props_clear();
|
void props_clear();
|
||||||
|
@ -568,18 +568,18 @@ int VoxelWorld::generation_get_size() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_PROPS_ENABLED
|
#ifdef MODULE_PROPS_ENABLED
|
||||||
void VoxelWorld::prop_add(Transform tarnsform, const Ref<PropData> &prop, const bool apply_voxel_scael) {
|
void VoxelWorld::prop_add(Transform transform, const Ref<PropData> &prop, const bool apply_voxel_scael) {
|
||||||
ERR_FAIL_COND(!prop.is_valid());
|
ERR_FAIL_COND(!prop.is_valid());
|
||||||
|
|
||||||
if (apply_voxel_scael) {
|
if (apply_voxel_scael) {
|
||||||
tarnsform = tarnsform.scaled(Vector3(get_voxel_scale(), get_voxel_scale(), get_voxel_scale()));
|
transform = transform.scaled(Vector3(get_voxel_scale(), get_voxel_scale(), get_voxel_scale()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 wp;
|
Vector3 wp;
|
||||||
wp = tarnsform.xform(wp);
|
wp = transform.xform(wp);
|
||||||
Ref<VoxelChunk> chunk = get_or_create_chunk_at_world_position(wp);
|
Ref<VoxelChunk> chunk = get_or_create_chunk_at_world_position(wp);
|
||||||
|
|
||||||
chunk->prop_add(tarnsform, prop);
|
chunk->prop_add(transform, prop);
|
||||||
|
|
||||||
int count = prop->get_prop_count();
|
int count = prop->get_prop_count();
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
@ -589,7 +589,7 @@ void VoxelWorld::prop_add(Transform tarnsform, const Ref<PropData> &prop, const
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform t = tarnsform * entry->get_transform();
|
Transform t = transform * entry->get_transform();
|
||||||
|
|
||||||
wp = t.xform(Vector3());
|
wp = t.xform(Vector3());
|
||||||
chunk = get_or_create_chunk_at_world_position(wp);
|
chunk = get_or_create_chunk_at_world_position(wp);
|
||||||
|
@ -173,7 +173,7 @@ public:
|
|||||||
int generation_get_size() const;
|
int generation_get_size() const;
|
||||||
|
|
||||||
#ifdef MODULE_PROPS_ENABLED
|
#ifdef MODULE_PROPS_ENABLED
|
||||||
void prop_add(Transform tarnsform, const Ref<PropData> &prop, const bool apply_voxel_scael = true);
|
void prop_add(Transform transform, const Ref<PropData> &prop, const bool apply_voxel_scael = true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Lights
|
//Lights
|
||||||
|
Loading…
Reference in New Issue
Block a user