Reimplemented mesh data instance creation in _prop_preprocess. Also don't set owners, so things won't show up in the editor.

This commit is contained in:
Relintai 2021-04-27 17:06:46 +02:00
parent 8667cc8eaf
commit 5b71d7a931

View File

@ -114,7 +114,7 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
Node *n = sc->instance();
add_child(n);
n->set_owner(this);
//n->set_owner(this);
Spatial *sp = Object::cast_to<Spatial>(n);
@ -153,9 +153,14 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
if (!mdr.is_valid())
continue;
//add to job
//job could merge textures if needed
//chunk->mesh_data_resource_add(t, mdr, mesh_data->get_texture());
MeshDataInstance *mdi = memnew(MeshDataInstance);
add_child(mdi);
//mdi->set_owner(this);
mdi->set_transform(t);
//not yet sure how it would be best to do this
//Maybe giving this class a material, and setting it could work
//mdi->set_material();
mdi->set_mesh_data(mdr);
continue;
}
@ -190,8 +195,8 @@ void PropInstance::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "set_prop_data", "get_prop_data");
BIND_VMETHOD(MethodInfo("_prop_preprocess",
PropertyInfo(Variant::TRANSFORM, "tarnsform"),
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData")));
PropertyInfo(Variant::TRANSFORM, "tarnsform"),
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", "tarnsform", "prop"), &PropInstance::_prop_preprocess);