From 1303ca6089c6c1e72d0658568056a7a61101ba0d Mon Sep 17 00:00:00 2001 From: TeslaRus Date: Sun, 4 Dec 2016 22:01:20 +0400 Subject: [PATCH] updated overlapped room checking algorithm; heavy boulders move logic updated; --- scripts/entity/entity_functions_common.lua | 19 +++++++++++-------- src/room.cpp | 8 +++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/scripts/entity/entity_functions_common.lua b/scripts/entity/entity_functions_common.lua index 5ba6044b4..34f410fa3 100644 --- a/scripts/entity/entity_functions_common.lua +++ b/scripts/entity/entity_functions_common.lua @@ -362,9 +362,8 @@ function boulder_heavy_init(id) setEntityTypeFlag(id, ENTITY_TYPE_HEAVYTRIGGER_ACTIVATOR); setEntityActivity(id, false); setEntityCallbackFlag(id, ENTITY_CALLBACK_COLLISION, 1); - createGhosts(id); local group = bit32.bor(COLLISION_GROUP_TRIGGERS, COLLISION_GROUP_CHARACTERS); - local mask = bit32.bor(COLLISION_GROUP_STATIC_ROOM, COLLISION_GROUP_STATIC_OBLECT); + local mask = bit32.bor(COLLISION_GROUP_STATIC_ROOM, COLLISION_GROUP_STATIC_OBLECT, COLLISION_GROUP_KINEMATIC); setEntityCollisionFlags(id, group, nil, mask); entity_funcs[id].onActivate = function(object_id, activator_id) @@ -377,13 +376,17 @@ function boulder_heavy_init(id) entity_funcs[id].onLoop = function(object_id) if(getEntityActivity(object_id)) then - moveEntityLocal(object_id, 0.0, 2048.0 * frame_time, 0.0); - local is_stopped, t = getEntitySphereTest(object_id, COLLISION_GROUP_STATIC_ROOM, 320.0, 0.0, 180.0, 0.0); - - local need_fix, dx, dy, dz = getEntityCollisionFix(object_id, COLLISION_GROUP_STATIC_ROOM); - if(need_fix) then - moveEntityGlobal(object_id, dx / 2, dy / 2, dz / 2); + local dy = 2560.0 * frame_time; + local R = 512; + local r = 256; + local test_y = R - r + dy; + local lim = dy / test_y; + local is_stopped, t = getEntitySphereTest(object_id, mask, r, 0.0, test_y, 0.0); + if(is_stopped) then + dy = t * test_y - (R - r); + is_stopped = dy < 16.0; end; + moveEntityLocal(object_id, 0.0, dy, 0.0); local is_dropped = dropEntity(object_id, frame_time, true); if(is_dropped and is_stopped) then diff --git a/src/room.cpp b/src/room.cpp index 59aacec12..27b5d419c 100644 --- a/src/room.cpp +++ b/src/room.cpp @@ -504,14 +504,16 @@ int Room_IsOverlapped(struct room_s *r0, struct room_s *r1) return 0; } - if(r0->bb_min[0] >= r1->bb_max[0] || r0->bb_max[0] <= r1->bb_min[0] || - r0->bb_min[1] >= r1->bb_max[1] || r0->bb_max[1] <= r1->bb_min[1] || + const int margin = TR_METERING_SECTORSIZE * 2; + + if(r0->bb_min[0] >= r1->bb_max[0] - margin || r0->bb_max[0] - margin <= r1->bb_min[0] || + r0->bb_min[1] >= r1->bb_max[1] - margin || r0->bb_max[1] - margin <= r1->bb_min[1] || r0->bb_min[2] >= r1->bb_max[2] || r0->bb_max[2] <= r1->bb_min[2]) { return 0; } - return !Room_IsJoined(r0, r1); + return 1; }