瀏覽代碼

world: generate collision end events

Daniele Bartolini 4 月之前
父節點
當前提交
f4e74a668b
共有 2 個文件被更改,包括 14 次插入0 次删除
  1. 1 0
      docs/changelog.rst
  2. 13 0
      src/world/physics_world_bullet.cpp

+ 1 - 0
docs/changelog.rst

@@ -42,6 +42,7 @@ Changelog
 * Runtime: fixed creating material uniforms of the wrong type in some circumnstances.
 * Runtime: fixed creating material uniforms of the wrong type in some circumnstances.
 * Runtime: fixed camera components not getting destroyed.
 * Runtime: fixed camera components not getting destroyed.
 * Runtime: fixed range-based culling of sound sources.
 * Runtime: fixed range-based culling of sound sources.
+* Runtime: fixed collision begin/stay generation.
 
 
 0.58.0 --- 01 Aug 2025
 0.58.0 --- 01 Aug 2025
 ----------------------
 ----------------------

+ 13 - 0
src/world/physics_world_bullet.cpp

@@ -1816,6 +1816,19 @@ struct PhysicsWorldImpl
 			event_stream::write(_events, EventType::PHYSICS_COLLISION, ev);
 			event_stream::write(_events, EventType::PHYSICS_COLLISION, ev);
 		}
 		}
 
 
+		auto cur = hash_set::begin(*_prev_pairs);
+		auto end = hash_set::end(*_prev_pairs);
+		for (; cur != end; ++cur) {
+			HASH_SET_SKIP_HOLE(*_prev_pairs, cur);
+
+			if (!hash_set::has(*_curr_pairs, *cur)) {
+				PhysicsCollisionEvent ev;
+				ev.type = PhysicsCollisionEvent::TOUCH_END;
+				decode_pair(ev.units[0], ev.units[1], *cur);
+				event_stream::write(_events, EventType::PHYSICS_COLLISION, ev);
+			}
+		}
+
 		exchange(_curr_pairs, _prev_pairs);
 		exchange(_curr_pairs, _prev_pairs);
 	}
 	}