mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-04-08 04:51:49 +02:00
Now PropInstance inherits from VisualInstance. Set up it's AABB calculation.
This commit is contained in:
parent
8cc8c4c7b4
commit
7cfebd1eaf
@ -104,6 +104,13 @@ void PropInstance::collision_layer_changed() {
|
||||
void PropInstance::collision_mask_changed() {
|
||||
}
|
||||
|
||||
AABB PropInstance::get_aabb() const {
|
||||
return _aabb;
|
||||
}
|
||||
PoolVector<Face3> PropInstance::get_faces(uint32_t p_usage_flags) const {
|
||||
return PoolVector<Face3>();
|
||||
}
|
||||
|
||||
void PropInstance::init_materials() {
|
||||
call("_init_materials");
|
||||
}
|
||||
@ -139,11 +146,17 @@ void PropInstance::_build() {
|
||||
}
|
||||
}
|
||||
|
||||
_aabb = AABB();
|
||||
_aabb.position = get_global_translation();
|
||||
|
||||
if (!_prop_data.is_valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
prop_preprocess(Transform(), _prop_data);
|
||||
|
||||
update_gizmos();
|
||||
_change_notify();
|
||||
}
|
||||
|
||||
void PropInstance::_build_finished() {
|
||||
@ -201,6 +214,9 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
|
||||
|
||||
add_child(twn);
|
||||
|
||||
//_aabb.merge_with(twn->get_aabb());
|
||||
_aabb.expand_to(t.get_origin());
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -220,6 +236,8 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
|
||||
|
||||
if (sp) {
|
||||
sp->set_transform(t);
|
||||
|
||||
_aabb.expand_to(t.get_origin());
|
||||
}
|
||||
|
||||
continue;
|
||||
@ -240,6 +258,8 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
|
||||
light->set_param(Light::PARAM_SPECULAR, light_data->get_light_specular());
|
||||
light->set_transform(t);
|
||||
|
||||
_aabb.expand_to(t.get_origin());
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -249,6 +269,8 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
|
||||
Node *static_body = static_body_data->processor_get_node_for(t);
|
||||
add_child(static_body);
|
||||
|
||||
_aabb.expand_to(t.get_origin());
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -262,6 +284,8 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
|
||||
continue;
|
||||
}
|
||||
|
||||
_aabb.merge_with(mdr->get_aabb());
|
||||
|
||||
MeshDataInstance *mdi = memnew(MeshDataInstance);
|
||||
add_child(mdi);
|
||||
mdi->set_transform(t);
|
||||
@ -292,6 +316,9 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
|
||||
|
||||
mdi->set_mesh_data(mdr);
|
||||
|
||||
//_aabb.merge_with(mdi->get_aabb());
|
||||
_aabb.expand_to(t.get_origin());
|
||||
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
@ -32,7 +32,7 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "scene/main/spatial.h"
|
||||
#include "scene/3d/visual_instance.h"
|
||||
|
||||
#include "scene/resources/material/material.h"
|
||||
|
||||
@ -40,8 +40,8 @@
|
||||
|
||||
#include "props/prop_data.h"
|
||||
|
||||
class PropInstance : public Spatial {
|
||||
GDCLASS(PropInstance, Spatial);
|
||||
class PropInstance : public VisualInstance {
|
||||
GDCLASS(PropInstance, VisualInstance);
|
||||
|
||||
public:
|
||||
Ref<PropData> get_prop_data();
|
||||
@ -59,6 +59,9 @@ public:
|
||||
virtual void collision_layer_changed();
|
||||
virtual void collision_mask_changed();
|
||||
|
||||
virtual AABB get_aabb() const;
|
||||
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
|
||||
|
||||
void init_materials();
|
||||
virtual void _init_materials();
|
||||
|
||||
@ -88,6 +91,8 @@ protected:
|
||||
|
||||
bool _build_queued;
|
||||
bool _building;
|
||||
|
||||
AABB _aabb;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -602,6 +602,10 @@ void PropInstanceMerger::_build_finished() {
|
||||
|
||||
if (_build_queued) {
|
||||
call_deferred("build");
|
||||
} else {
|
||||
update_gizmos();
|
||||
|
||||
_change_notify();
|
||||
}
|
||||
}
|
||||
|
||||
@ -642,6 +646,8 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
|
||||
Transform et = t * static_body_data->get_collision_shape_transform(j);
|
||||
|
||||
_job->add_collision_shape(collision_shape, et, true);
|
||||
|
||||
_aabb.expand_to(t.get_origin());
|
||||
}
|
||||
}
|
||||
|
||||
@ -656,6 +662,8 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
|
||||
if (twd.is_valid()) {
|
||||
_job->add_tiled_wall(tiled_wall_data, t);
|
||||
|
||||
_aabb.expand_to(t.get_origin());
|
||||
|
||||
if (tiled_wall_data->get_collision()) {
|
||||
Ref<BoxShape> tws;
|
||||
tws.instance();
|
||||
@ -694,6 +702,7 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
|
||||
|
||||
if (sp) {
|
||||
sp->set_transform(t);
|
||||
_aabb.expand_to(t.get_origin());
|
||||
}
|
||||
|
||||
continue;
|
||||
@ -720,6 +729,8 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
|
||||
|
||||
_job->add_light(light);
|
||||
|
||||
_aabb.expand_to(t.get_origin());
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -733,10 +744,14 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
|
||||
continue;
|
||||
}
|
||||
|
||||
_aabb.merge_with(mdr->get_aabb());
|
||||
|
||||
_job->add_mesh(mesh_data, t);
|
||||
|
||||
for (int j = 0; j < mdr->get_collision_shape_count(); ++j) {
|
||||
_job->add_collision_shape(mdr->get_collision_shape(j), t * mdr->get_collision_shape_offset(j));
|
||||
Transform ct = t * mdr->get_collision_shape_offset(j);
|
||||
_job->add_collision_shape(mdr->get_collision_shape(j), ct);
|
||||
_aabb.expand_to(ct.get_origin());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user