mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-22 10:57:30 +01:00
Added add_textures_into method to PropData.
This commit is contained in:
parent
8be82ec4e4
commit
8ba8209bc2
@ -1,5 +1,7 @@
|
||||
#include "prop_data.h"
|
||||
|
||||
#include "prop_data_prop.h"
|
||||
|
||||
bool PropData::get_snap_to_mesh() {
|
||||
return _snap_to_mesh;
|
||||
}
|
||||
@ -53,6 +55,26 @@ void PropData::set_props(const Vector<Variant> &props) {
|
||||
}
|
||||
}
|
||||
|
||||
void PropData::add_textures_into(Ref<TexturePacker> texture_packer) {
|
||||
ERR_FAIL_COND(!texture_packer.is_valid());
|
||||
|
||||
for (int i = 0; i < _props.size(); ++i) {
|
||||
Ref<PropDataEntry> entry = _props.get(i);
|
||||
|
||||
Ref<PropDataMesh> pmesh = entry;
|
||||
|
||||
if (pmesh.is_valid() && pmesh->get_texture().is_valid()) {
|
||||
texture_packer->add_texture(pmesh->get_texture());
|
||||
}
|
||||
|
||||
Ref<PropDataProp> pdataprop = entry;
|
||||
|
||||
if (pdataprop.is_valid() && pdataprop->get_prop().is_valid()) {
|
||||
pdataprop->get_prop()->add_textures_into(texture_packer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PropData::PropData() {
|
||||
_snap_to_mesh = false;
|
||||
_snap_axis = Vector3(0, -1, 0);
|
||||
@ -80,4 +102,6 @@ void PropData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_props"), &PropData::get_props);
|
||||
ClassDB::bind_method(D_METHOD("set_props", "props"), &PropData::set_props);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "props", PROPERTY_HINT_NONE, "17/17:PropDataEntry", PROPERTY_USAGE_DEFAULT, "PropDataEntry"), "set_props", "get_props");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropData::add_textures_into);
|
||||
}
|
||||
|
@ -5,6 +5,9 @@
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "prop_data_entry.h"
|
||||
#include "prop_data_mesh.h"
|
||||
|
||||
#include "../../texture_packer/texture_packer.h"
|
||||
|
||||
class PropData : public Resource {
|
||||
GDCLASS(PropData, Resource);
|
||||
@ -25,6 +28,8 @@ public:
|
||||
|
||||
Vector<Variant> get_props();
|
||||
void set_props(const Vector<Variant> &props);
|
||||
|
||||
void add_textures_into(Ref<TexturePacker> texture_packer);
|
||||
|
||||
PropData();
|
||||
~PropData();
|
||||
|
Loading…
Reference in New Issue
Block a user