Implemented handling the new collider_z_offset property for merged TiledWalls.

This commit is contained in:
Relintai 2022-07-31 14:04:26 +02:00
parent 0227b18d06
commit 40d9d6b49b

View File

@ -183,7 +183,7 @@ void PropInstanceMerger::meshes_create(const int num) {
if (get_world().is_valid()) { if (get_world().is_valid()) {
VS::get_singleton()->instance_set_scenario(mesh_instance_rid, get_world()->get_scenario()); VS::get_singleton()->instance_set_scenario(mesh_instance_rid, get_world()->get_scenario());
} }
RID mesh_rid = VS::get_singleton()->mesh_create(); RID mesh_rid = VS::get_singleton()->mesh_create();
@ -414,7 +414,7 @@ void PropInstanceMerger::debug_mesh_send() {
if (_debug_mesh_array.size() == 0) { if (_debug_mesh_array.size() == 0) {
return; return;
} }
SceneTree *st = SceneTree::get_singleton(); SceneTree *st = SceneTree::get_singleton();
@ -586,7 +586,7 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
if (!e.is_valid()) { if (!e.is_valid()) {
continue; continue;
} }
Transform t = transform * e->get_transform(); Transform t = transform * e->get_transform();
@ -597,7 +597,7 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
if (!p.is_valid()) { if (!p.is_valid()) {
continue; continue;
} }
prop_preprocess(t, p); prop_preprocess(t, p);
@ -607,22 +607,27 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
Ref<PropDataTiledWall> tiled_wall_data = e; Ref<PropDataTiledWall> tiled_wall_data = e;
if (tiled_wall_data.is_valid()) { if (tiled_wall_data.is_valid()) {
_job->add_tiled_wall(tiled_wall_data, t); Ref<TiledWallData> twd = tiled_wall_data->get_data();
if (tiled_wall_data->get_collision()) { if (twd.is_valid()) {
Ref<BoxShape> tws; _job->add_tiled_wall(tiled_wall_data, t);
tws.instance();
float hew = tiled_wall_data->get_width() / 2.0; if (tiled_wall_data->get_collision()) {
float heh = tiled_wall_data->get_heigth() / 2.0; Ref<BoxShape> tws;
tws.instance();
tws->set_extents(Vector3(hew, heh, 0.01)); float hew = tiled_wall_data->get_width() / 2.0;
float heh = tiled_wall_data->get_heigth() / 2.0;
Transform tt = t; tws->set_extents(Vector3(hew, heh, 0.01));
//tt.origin += Vector3(hew, heh, 0);
tt.translate(hew, heh, 0);
_job->add_collision_shape(tws, tt, true); Transform et = e->get_transform() * Transform(Basis(), Vector3(0, 0, twd->get_colldier_z_offset()));
Transform tt = transform * et;
//tt.origin += Vector3(hew, heh, 0);
tt.translate(hew, heh, 0);
_job->add_collision_shape(tws, tt, true);
}
} }
continue; continue;
@ -635,7 +640,7 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
if (!sc.is_valid()) { if (!sc.is_valid()) {
continue; continue;
} }
Node *n = sc->instance(); Node *n = sc->instance();
add_child(n); add_child(n);
@ -677,7 +682,7 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
if (!mdr.is_valid()) { if (!mdr.is_valid()) {
continue; continue;
} }
_job->add_mesh(mesh_data, t); _job->add_mesh(mesh_data, t);