mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-12 10:15:12 +01:00
Improved the way props work.
This commit is contained in:
parent
916676cfab
commit
306dc575d8
5
SCsub
5
SCsub
@ -23,7 +23,10 @@ env.add_source_files(env.modules_sources,"world/voxel_chunk.cpp")
|
||||
env.add_source_files(env.modules_sources,"meshers/cubic_mesher/voxel_mesher_cubic.cpp")
|
||||
env.add_source_files(env.modules_sources,"meshers/cubic_mesher/voxel_cube_points.cpp")
|
||||
|
||||
env.add_source_files(env.modules_sources,"props/voxelman_prop_entry.cpp")
|
||||
env.add_source_files(env.modules_sources,"props/voxelman_prop.cpp")
|
||||
env.add_source_files(env.modules_sources,"props/voxelman_prop_entry.cpp")
|
||||
env.add_source_files(env.modules_sources,"props/voxelman_prop_scene.cpp")
|
||||
env.add_source_files(env.modules_sources,"props/voxelman_prop_mesh.cpp")
|
||||
env.add_source_files(env.modules_sources,"props/voxelman_prop_light.cpp")
|
||||
|
||||
env.add_source_files(env.modules_sources,"level_generator/voxelman_level_generator.cpp")
|
||||
|
@ -1,118 +1,21 @@
|
||||
#include "voxelman_prop_entry.h"
|
||||
|
||||
#include "voxelman_prop.h"
|
||||
|
||||
Ref<MeshDataResource> VoxelmanPropEntry::get_mesh() const {
|
||||
return _mesh;
|
||||
Transform VoxelmanPropEntry::get_transform() const {
|
||||
return _transform;
|
||||
}
|
||||
void VoxelmanPropEntry::set_mesh(const Ref<MeshDataResource> mesh) {
|
||||
_mesh = mesh;
|
||||
}
|
||||
|
||||
int VoxelmanPropEntry::get_has_light() const {
|
||||
return _has_light;
|
||||
}
|
||||
void VoxelmanPropEntry::set_has_light(const int value){
|
||||
_has_light = value;
|
||||
}
|
||||
|
||||
Color VoxelmanPropEntry::get_light_color() const {
|
||||
return _light_color;
|
||||
}
|
||||
void VoxelmanPropEntry::set_light_color(const Color value) {
|
||||
_light_color = value;
|
||||
}
|
||||
|
||||
int VoxelmanPropEntry::get_light_size() const {
|
||||
return _light_size;
|
||||
}
|
||||
void VoxelmanPropEntry::set_light_size(const int value) {
|
||||
_has_light = value;
|
||||
}
|
||||
|
||||
Ref<PackedScene> VoxelmanPropEntry::get_scene() const {
|
||||
return _scene;
|
||||
}
|
||||
void VoxelmanPropEntry::set_scene(const Ref<PackedScene> value) {
|
||||
_scene = value;
|
||||
}
|
||||
|
||||
Vector3 VoxelmanPropEntry::get_position() const {
|
||||
return _position;
|
||||
}
|
||||
void VoxelmanPropEntry::set_position(const Vector3 value) {
|
||||
_position = value;
|
||||
}
|
||||
|
||||
Vector3 VoxelmanPropEntry::get_rotation() const {
|
||||
return _rotation;
|
||||
}
|
||||
void VoxelmanPropEntry::set_rotation(const Vector3 value) {
|
||||
_rotation = value;
|
||||
}
|
||||
|
||||
Vector3 VoxelmanPropEntry::get_scale() const {
|
||||
return _scale;
|
||||
}
|
||||
void VoxelmanPropEntry::set_scale(const Vector3 value) {
|
||||
_scale = value;
|
||||
}
|
||||
|
||||
Ref<VoxelmanProp> VoxelmanPropEntry::get_prop() const {
|
||||
return _prop;
|
||||
}
|
||||
void VoxelmanPropEntry::set_prop(const Ref<VoxelmanProp> prop) {
|
||||
_prop = prop;
|
||||
void VoxelmanPropEntry::set_transform(const Transform value) {
|
||||
_transform = value;
|
||||
}
|
||||
|
||||
VoxelmanPropEntry::VoxelmanPropEntry() {
|
||||
_has_light = false;
|
||||
_light_size = 5;
|
||||
|
||||
_scale = Vector3(1.0, 1.0, 1.0);
|
||||
}
|
||||
VoxelmanPropEntry::~VoxelmanPropEntry() {
|
||||
if (_mesh.is_valid())
|
||||
_mesh.unref();
|
||||
|
||||
if (_scene.is_valid())
|
||||
_scene.unref();
|
||||
}
|
||||
|
||||
void VoxelmanPropEntry::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_mesh"), &VoxelmanPropEntry::get_mesh);
|
||||
ClassDB::bind_method(D_METHOD("set_mesh", "value"), &VoxelmanPropEntry::set_mesh);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "MeshDataResource"), "set_mesh", "get_mesh");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_has_light"), &VoxelmanPropEntry::get_has_light);
|
||||
ClassDB::bind_method(D_METHOD("set_has_light", "value"), &VoxelmanPropEntry::set_has_light);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "has_light"), "set_has_light", "get_has_light");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_light_color"), &VoxelmanPropEntry::get_light_color);
|
||||
ClassDB::bind_method(D_METHOD("set_light_color", "value"), &VoxelmanPropEntry::set_light_color);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "light_color"), "set_light_color", "get_light_color");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_light_size"), &VoxelmanPropEntry::get_light_size);
|
||||
ClassDB::bind_method(D_METHOD("set_light_size", "value"), &VoxelmanPropEntry::set_light_size);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_size"), "set_light_size", "get_light_size");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_scene"), &VoxelmanPropEntry::get_scene);
|
||||
ClassDB::bind_method(D_METHOD("set_scene", "value"), &VoxelmanPropEntry::set_scene);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_prop"), &VoxelmanPropEntry::get_prop);
|
||||
ClassDB::bind_method(D_METHOD("set_prop", "value"), &VoxelmanPropEntry::set_prop);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanProp"), "set_prop", "get_prop");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_position"), &VoxelmanPropEntry::get_position);
|
||||
ClassDB::bind_method(D_METHOD("set_position", "value"), &VoxelmanPropEntry::set_position);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position"), "set_position", "get_position");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_rotation"), &VoxelmanPropEntry::get_rotation);
|
||||
ClassDB::bind_method(D_METHOD("set_rotation", "value"), &VoxelmanPropEntry::set_rotation);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation"), "set_rotation", "get_rotation");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_scale"), &VoxelmanPropEntry::get_scale);
|
||||
ClassDB::bind_method(D_METHOD("set_scale", "value"), &VoxelmanPropEntry::set_scale);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale"), "set_scale", "get_scale");
|
||||
ClassDB::bind_method(D_METHOD("get_transform"), &VoxelmanPropEntry::get_transform);
|
||||
ClassDB::bind_method(D_METHOD("set_transform", "value"), &VoxelmanPropEntry::set_transform);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform");
|
||||
}
|
||||
|
@ -1,45 +1,16 @@
|
||||
#ifndef VOXELMAN_PROP_DATA_H
|
||||
#define VOXELMAN_PROP_DATA_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "core/math/vector3.h"
|
||||
#include "core/color.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
#include "../../entity_spell_system/meshes/mesh_data_resource.h"
|
||||
|
||||
class VoxelmanProp;
|
||||
#include "core/resource.h"
|
||||
#include "core/math/transform.h"
|
||||
|
||||
class VoxelmanPropEntry : public Resource {
|
||||
GDCLASS(VoxelmanPropEntry, Resource);
|
||||
|
||||
public:
|
||||
Ref<MeshDataResource> get_mesh() const;
|
||||
void set_mesh(const Ref<MeshDataResource> mesh);
|
||||
|
||||
int get_has_light() const;
|
||||
void set_has_light(const int value);
|
||||
|
||||
Color get_light_color() const;
|
||||
void set_light_color(const Color value);
|
||||
|
||||
int get_light_size() const;
|
||||
void set_light_size(const int value);
|
||||
|
||||
Ref<PackedScene> get_scene() const;
|
||||
void set_scene(const Ref<PackedScene> value);
|
||||
|
||||
Vector3 get_position() const;
|
||||
void set_position(const Vector3 value);
|
||||
|
||||
Vector3 get_rotation() const;
|
||||
void set_rotation(const Vector3 value);
|
||||
|
||||
Vector3 get_scale() const;
|
||||
void set_scale(const Vector3 value);
|
||||
|
||||
Ref<VoxelmanProp> get_prop() const;
|
||||
void set_prop(const Ref<VoxelmanProp> prop);
|
||||
Transform get_transform() const;
|
||||
void set_transform(const Transform value);
|
||||
|
||||
VoxelmanPropEntry();
|
||||
~VoxelmanPropEntry();
|
||||
@ -48,19 +19,8 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Ref<MeshDataResource> _mesh;
|
||||
|
||||
bool _has_light;
|
||||
Color _light_color;
|
||||
int _light_size;
|
||||
|
||||
Ref<PackedScene> _scene;
|
||||
|
||||
Ref<VoxelmanProp> _prop;
|
||||
|
||||
Vector3 _position;
|
||||
Vector3 _rotation;
|
||||
Vector3 _scale;
|
||||
Transform _transform;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
32
props/voxelman_prop_light.cpp
Normal file
32
props/voxelman_prop_light.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "voxelman_prop_light.h"
|
||||
|
||||
|
||||
Color VoxelmanPropLight::get_light_color() const {
|
||||
return _light_color;
|
||||
}
|
||||
void VoxelmanPropLight::set_light_color(const Color value) {
|
||||
_light_color = value;
|
||||
}
|
||||
|
||||
int VoxelmanPropLight::get_light_size() const {
|
||||
return _light_size;
|
||||
}
|
||||
void VoxelmanPropLight::set_light_size(const int value) {
|
||||
_light_size = value;
|
||||
}
|
||||
|
||||
VoxelmanPropLight::VoxelmanPropLight() {
|
||||
_light_size = 5;
|
||||
}
|
||||
VoxelmanPropLight::~VoxelmanPropLight() {
|
||||
}
|
||||
|
||||
void VoxelmanPropLight::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_light_color"), &VoxelmanPropLight::get_light_color);
|
||||
ClassDB::bind_method(D_METHOD("set_light_color", "value"), &VoxelmanPropLight::set_light_color);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "light_color"), "set_light_color", "get_light_color");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_light_size"), &VoxelmanPropLight::get_light_size);
|
||||
ClassDB::bind_method(D_METHOD("set_light_size", "value"), &VoxelmanPropLight::set_light_size);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_size"), "set_light_size", "get_light_size");
|
||||
}
|
29
props/voxelman_prop_light.h
Normal file
29
props/voxelman_prop_light.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef VOXELMAN_PROP_LIGHT_H
|
||||
#define VOXELMAN_PROP_LIGHT_H
|
||||
|
||||
#include "voxelman_prop_entry.h"
|
||||
|
||||
#include "core/color.h"
|
||||
|
||||
class VoxelmanPropLight : public VoxelmanPropEntry {
|
||||
GDCLASS(VoxelmanPropLight, VoxelmanPropEntry);
|
||||
|
||||
public:
|
||||
Color get_light_color() const;
|
||||
void set_light_color(const Color value);
|
||||
|
||||
int get_light_size() const;
|
||||
void set_light_size(const int value);
|
||||
|
||||
VoxelmanPropLight();
|
||||
~VoxelmanPropLight();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Color _light_color;
|
||||
int _light_size;
|
||||
};
|
||||
|
||||
#endif
|
21
props/voxelman_prop_mesh.cpp
Normal file
21
props/voxelman_prop_mesh.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "voxelman_prop_mesh.h"
|
||||
|
||||
Ref<MeshDataResource> VoxelmanPropMesh::get_mesh() const {
|
||||
return _mesh;
|
||||
}
|
||||
void VoxelmanPropMesh::set_mesh(const Ref<MeshDataResource> mesh) {
|
||||
_mesh = mesh;
|
||||
}
|
||||
|
||||
VoxelmanPropMesh::VoxelmanPropMesh() {
|
||||
}
|
||||
VoxelmanPropMesh::~VoxelmanPropMesh() {
|
||||
if (_mesh.is_valid())
|
||||
_mesh.unref();
|
||||
}
|
||||
|
||||
void VoxelmanPropMesh::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_mesh"), &VoxelmanPropMesh::get_mesh);
|
||||
ClassDB::bind_method(D_METHOD("set_mesh", "value"), &VoxelmanPropMesh::set_mesh);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "MeshDataResource"), "set_mesh", "get_mesh");
|
||||
}
|
25
props/voxelman_prop_mesh.h
Normal file
25
props/voxelman_prop_mesh.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef VOXELMAN_PROP_MESH_H
|
||||
#define VOXELMAN_PROP_MESH_H
|
||||
|
||||
#include "voxelman_prop_entry.h"
|
||||
|
||||
#include "../../entity_spell_system/meshes/mesh_data_resource.h"
|
||||
|
||||
class VoxelmanPropMesh : public VoxelmanPropEntry {
|
||||
GDCLASS(VoxelmanPropMesh, VoxelmanPropEntry);
|
||||
|
||||
public:
|
||||
Ref<MeshDataResource> get_mesh() const;
|
||||
void set_mesh(const Ref<MeshDataResource> mesh);
|
||||
|
||||
VoxelmanPropMesh();
|
||||
~VoxelmanPropMesh();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Ref<MeshDataResource> _mesh;
|
||||
};
|
||||
|
||||
#endif
|
21
props/voxelman_prop_scene.cpp
Normal file
21
props/voxelman_prop_scene.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "voxelman_prop_scene.h"
|
||||
|
||||
Ref<PackedScene> VoxelmanPropScene::get_scene() const {
|
||||
return _scene;
|
||||
}
|
||||
void VoxelmanPropScene::set_scene(const Ref<PackedScene> value) {
|
||||
_scene = value;
|
||||
}
|
||||
|
||||
VoxelmanPropScene::VoxelmanPropScene() {
|
||||
}
|
||||
VoxelmanPropScene::~VoxelmanPropScene() {
|
||||
if (_scene.is_valid())
|
||||
_scene.unref();
|
||||
}
|
||||
|
||||
void VoxelmanPropScene::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_scene"), &VoxelmanPropScene::get_scene);
|
||||
ClassDB::bind_method(D_METHOD("set_scene", "value"), &VoxelmanPropScene::set_scene);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene");
|
||||
}
|
25
props/voxelman_prop_scene.h
Normal file
25
props/voxelman_prop_scene.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef VOXELMAN_PROP_SCENE_H
|
||||
#define VOXELMAN_PROP_SCENE_H
|
||||
|
||||
#include "voxelman_prop_entry.h"
|
||||
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
class VoxelmanPropScene : public VoxelmanPropEntry {
|
||||
GDCLASS(VoxelmanPropScene, VoxelmanPropEntry);
|
||||
|
||||
public:
|
||||
Ref<PackedScene> get_scene() const;
|
||||
void set_scene(const Ref<PackedScene> value);
|
||||
|
||||
VoxelmanPropScene();
|
||||
~VoxelmanPropScene();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Ref<PackedScene> _scene;
|
||||
};
|
||||
|
||||
#endif
|
@ -16,8 +16,11 @@
|
||||
#include "meshers/cubic_mesher/voxel_mesher_cubic.h"
|
||||
#include "meshers/cubic_mesher/voxel_cube_points.h"
|
||||
|
||||
#include "props/voxelman_prop_entry.h"
|
||||
#include "props/voxelman_prop.h"
|
||||
#include "props/voxelman_prop_entry.h"
|
||||
#include "props/voxelman_prop_scene.h"
|
||||
#include "props/voxelman_prop_mesh.h"
|
||||
#include "props/voxelman_prop_light.h"
|
||||
|
||||
#include "level_generator/voxelman_level_generator.h"
|
||||
|
||||
@ -39,8 +42,11 @@ void register_voxelman_types() {
|
||||
ClassDB::register_class<VoxelMesherCubic>();
|
||||
ClassDB::register_class<VoxelCubePoints>();
|
||||
|
||||
ClassDB::register_class<VoxelmanPropEntry>();
|
||||
ClassDB::register_class<VoxelmanProp>();
|
||||
ClassDB::register_class<VoxelmanPropEntry>();
|
||||
ClassDB::register_class<VoxelmanPropScene>();
|
||||
ClassDB::register_class<VoxelmanPropMesh>();
|
||||
ClassDB::register_class<VoxelmanPropLight>();
|
||||
|
||||
ClassDB::register_class<VoxelmanLevelGenerator>();
|
||||
}
|
||||
|
@ -275,23 +275,23 @@ void VoxelChunk::add_lights_into(Array target) {
|
||||
|
||||
void VoxelChunk::add_unique_lights_into(Array target) {
|
||||
for (int i = 0; i < _voxel_lights.size(); ++i) {
|
||||
Ref<VoxelLight> l = _voxel_lights.get(i);
|
||||
|
||||
bool append = true;
|
||||
for (int j = 0; j < target.size(); ++j) {
|
||||
Ref<VoxelLight> l2 = target.get(j);
|
||||
|
||||
if (!l2.is_valid())
|
||||
continue;
|
||||
|
||||
if (l2->get_world_position() == l->get_world_position() && l2->get_size() == l->get_size()) {
|
||||
append = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (append)
|
||||
target.append(l);
|
||||
Ref<VoxelLight> l = _voxel_lights.get(i);
|
||||
|
||||
bool append = true;
|
||||
for (int j = 0; j < target.size(); ++j) {
|
||||
Ref<VoxelLight> l2 = target.get(j);
|
||||
|
||||
if (!l2.is_valid())
|
||||
continue;
|
||||
|
||||
if (l2->get_world_position() == l->get_world_position() && l2->get_size() == l->get_size()) {
|
||||
append = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (append)
|
||||
target.append(l);
|
||||
}
|
||||
}
|
||||
|
||||
@ -335,9 +335,7 @@ void VoxelChunk::clear_baked_lights() {
|
||||
void VoxelChunk::add_prop_mesh(const Ref<MeshDataResource> mesh, const Vector3 position, const Vector3 rotation, const Vector3 scale) {
|
||||
VCPropData data;
|
||||
|
||||
data.position = position;
|
||||
data.rotation = rotation;
|
||||
data.scale = scale;
|
||||
data.transform = Transform(Basis(rotation).scaled(scale), position);
|
||||
|
||||
data.mesh = mesh;
|
||||
|
||||
@ -347,9 +345,7 @@ void VoxelChunk::add_prop_mesh(const Ref<MeshDataResource> mesh, const Vector3 p
|
||||
void VoxelChunk::add_prop_spawned(const Ref<PackedScene> scene, const Vector3 position, const Vector3 rotation, const Vector3 scale) {
|
||||
VCPropData data;
|
||||
|
||||
data.position = position;
|
||||
data.rotation = rotation;
|
||||
data.scale = scale;
|
||||
data.transform = Transform(Basis(rotation).scaled(scale), position);
|
||||
|
||||
data.scene = scene;
|
||||
|
||||
@ -359,9 +355,7 @@ void VoxelChunk::add_prop_spawned(const Ref<PackedScene> scene, const Vector3 po
|
||||
void VoxelChunk::add_prop(const Ref<VoxelmanProp> prop, const Vector3 position, const Vector3 rotation, const Vector3 scale) {
|
||||
VCPropData data;
|
||||
|
||||
data.position = position;
|
||||
data.rotation = rotation;
|
||||
data.scale = scale;
|
||||
data.transform = Transform(Basis(rotation).scaled(scale), position);
|
||||
|
||||
data.mesh = prop;
|
||||
|
||||
@ -413,19 +407,7 @@ void VoxelChunk::process_props() {
|
||||
for (int i = 0; i < _props.size(); ++i) {
|
||||
VCPropData prop = _props[i];
|
||||
|
||||
Transform transform(Basis(prop.rotation).scaled(prop.scale), prop.position);
|
||||
|
||||
if (prop.mesh.is_valid()) {
|
||||
_mesher->add_mesh_data_resource_transform(prop.mesh, transform);
|
||||
}
|
||||
|
||||
if (prop.prop.is_valid()) {
|
||||
process_prop(prop.prop, transform);
|
||||
}
|
||||
|
||||
if (prop.scene.is_valid()) {
|
||||
spawn_prop(prop.scene, transform);
|
||||
}
|
||||
process_prop(prop.prop, prop.transform);
|
||||
}
|
||||
|
||||
_mesher->bake_colors(_buffer);
|
||||
@ -433,29 +415,16 @@ void VoxelChunk::process_props() {
|
||||
_mesher->build_mesh(_prop_mesh_rid);
|
||||
}
|
||||
|
||||
void VoxelChunk::process_prop_light(Ref<VoxelmanProp> prop, const Transform transform) {
|
||||
void VoxelChunk::process_prop_light(Ref<VoxelmanPropLight> prop, const Transform transform) {
|
||||
ERR_FAIL_COND(!prop.is_valid());
|
||||
|
||||
for (int i = 0; i < prop->get_prop_count(); ++i) {
|
||||
Ref<VoxelmanPropEntry> data = prop->get_prop(i);
|
||||
Transform pt = prop->get_transform();
|
||||
|
||||
if (!data.is_valid())
|
||||
continue;
|
||||
pt = transform * pt;
|
||||
|
||||
Transform pt(Basis(data->get_rotation()).scaled(data->get_scale()), data->get_position());
|
||||
Vector3 lp = pt.xform_inv(Vector3());
|
||||
|
||||
pt = transform * pt;
|
||||
|
||||
if (data->get_has_light()) {
|
||||
Vector3 lp = pt.xform_inv(Vector3());
|
||||
|
||||
create_voxel_light(data->get_light_color(), data->get_light_size(), (int)lp.x, (int)lp.y, (int)lp.z);
|
||||
}
|
||||
|
||||
if (data->get_prop().is_valid()) {
|
||||
process_prop_light(data->get_prop(), pt);
|
||||
}
|
||||
}
|
||||
create_voxel_light(prop->get_light_color(), prop->get_light_size(), (int)lp.x, (int)lp.y, (int)lp.z);
|
||||
}
|
||||
|
||||
void VoxelChunk::process_prop(Ref<VoxelmanProp> prop, const Transform transform) {
|
||||
@ -467,18 +436,21 @@ void VoxelChunk::process_prop(Ref<VoxelmanProp> prop, const Transform transform)
|
||||
if (!data.is_valid())
|
||||
continue;
|
||||
|
||||
Transform pt(Basis(data->get_rotation()).scaled(data->get_scale()), data->get_position());
|
||||
Transform pt = data->get_transform();
|
||||
|
||||
if (data->get_mesh().is_valid()) {
|
||||
_mesher->add_mesh_data_resource_transform(data->get_mesh(), pt);
|
||||
Ref<VoxelmanPropMesh> mesh = data;
|
||||
if (mesh.is_valid()) {
|
||||
_mesher->add_mesh_data_resource_transform(mesh->get_mesh(), pt);
|
||||
}
|
||||
|
||||
if (data->get_scene().is_valid()) {
|
||||
spawn_prop(data->get_scene(), pt);
|
||||
Ref<VoxelmanPropScene> scene = data;
|
||||
if (scene.is_valid()) {
|
||||
spawn_prop(scene->get_scene(), pt);
|
||||
}
|
||||
|
||||
if (data->get_prop().is_valid()) {
|
||||
process_prop(data->get_prop(), pt);
|
||||
Ref<VoxelmanPropLight> light = data;
|
||||
if (light.is_valid()) {
|
||||
process_prop_light(data, transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -875,4 +847,3 @@ void VoxelChunk::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("draw_debug_voxel_lights"), &VoxelChunk::draw_debug_voxel_lights);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,9 @@
|
||||
#include "../../entity_spell_system/meshes/mesh_data_resource.h"
|
||||
#include "../props/voxelman_prop.h"
|
||||
#include "../props/voxelman_prop_entry.h"
|
||||
#include "../props/voxelman_prop_scene.h"
|
||||
#include "../props/voxelman_prop_mesh.h"
|
||||
#include "../props/voxelman_prop_light.h"
|
||||
|
||||
class VoxelWorld;
|
||||
|
||||
@ -113,7 +116,7 @@ public:
|
||||
void process_prop_lights();
|
||||
void process_props();
|
||||
void process_prop(Ref<VoxelmanProp> prop, const Transform transform = Transform());
|
||||
void process_prop_light(Ref<VoxelmanProp> prop, const Transform transform = Transform());
|
||||
void process_prop_light(Ref<VoxelmanPropLight> prop, const Transform transform = Transform());
|
||||
void spawn_prop(const Ref<PackedScene> scene, const Transform transform = Transform());
|
||||
|
||||
void build_prop_meshes();
|
||||
@ -144,9 +147,7 @@ public:
|
||||
|
||||
protected:
|
||||
struct VCPropData {
|
||||
Vector3 position;
|
||||
Vector3 rotation;
|
||||
Vector3 scale;
|
||||
Transform transform;
|
||||
|
||||
Ref<MeshDataResource> mesh;
|
||||
Ref<VoxelmanProp> prop;
|
||||
|
Loading…
Reference in New Issue
Block a user