refactor(physics): rename isSensor to isTrigger (Unity/UE terminology)
UE calls it Trigger (Overlap Events / Trigger preset) and Unity's UI says "Is Trigger"; "sensor" is the physics-backend term (Jolt sensor, Box2D sensor). Rename the component/record flag and the Inspector label. Scene files now persist "IsTrigger" with backward-compatible read of the old "IsSensor" key.
This commit is contained in:
@@ -390,7 +390,7 @@ namespace Engine {
|
||||
rec.halfHeight != halfHeight ||
|
||||
rec.compound != rb.compound ||
|
||||
rec.mass != rb.mass ||
|
||||
rec.isSensor != rb.isSensor) {
|
||||
rec.isTrigger != rb.isTrigger) {
|
||||
// 类型/碰撞体/质量变更 → 重建(简单正确,重置速度可接受)
|
||||
bi.RemoveBody(rec.id);
|
||||
bi.DestroyBody(rec.id);
|
||||
@@ -860,7 +860,7 @@ namespace Engine {
|
||||
settings.mFriction = rb.friction;
|
||||
settings.mRestitution = rb.restitution;
|
||||
settings.mUserData = entityBits; // 事件回调:Body → 实体位模式反查
|
||||
settings.mIsSensor = rb.isSensor; // 传感器:只收 Added/Removed,不解算
|
||||
settings.mIsSensor = rb.isTrigger; // 触发器:只收 Added/Removed,不解算
|
||||
|
||||
const JPH::BodyID id = bi.CreateAndAddBody(
|
||||
settings, dynamic ? JPH::EActivation::Activate : JPH::EActivation::DontActivate);
|
||||
@@ -873,7 +873,7 @@ namespace Engine {
|
||||
ExtractShapeParams(rb, rec.radius, rec.halfHeight);
|
||||
rec.compound = rb.compound;
|
||||
rec.mass = rb.mass;
|
||||
rec.isSensor = rb.isSensor;
|
||||
rec.isTrigger = rb.isTrigger;
|
||||
rec.lastPos = tr.GetPosition();
|
||||
rec.lastRot = tr.GetRotationQuat();
|
||||
m_Bodies[entityBits] = rec;
|
||||
|
||||
@@ -306,7 +306,7 @@ namespace Engine::Serialization {
|
||||
out << YAML::Key << "Friction" << YAML::Value << rb->friction;
|
||||
out << YAML::Key << "Restitution" << YAML::Value
|
||||
<< rb->restitution;
|
||||
out << YAML::Key << "IsSensor" << YAML::Value << rb->isSensor;
|
||||
out << YAML::Key << "IsTrigger" << YAML::Value << rb->isTrigger;
|
||||
// bodyId/bodyValid/velocity 由 PhysicsWorld 对账重建,不存
|
||||
out << YAML::Key << "Active" << YAML::Value << rb->active;
|
||||
out << YAML::EndMap;
|
||||
@@ -616,7 +616,9 @@ namespace Engine::Serialization {
|
||||
rb.gravityScale = n["GravityScale"].as<f32>(rb.gravityScale);
|
||||
rb.friction = n["Friction"].as<f32>(rb.friction);
|
||||
rb.restitution = n["Restitution"].as<f32>(rb.restitution);
|
||||
rb.isSensor = n["IsSensor"].as<bool>(rb.isSensor);
|
||||
// 新键 IsTrigger;旧场景 IsSensor 兼容读(缺键 as 返回 fallback 安全)
|
||||
rb.isTrigger = n["IsTrigger"].as<bool>(
|
||||
n["IsSensor"].as<bool>(rb.isTrigger));
|
||||
rb.active = n["Active"].as<bool>(true);
|
||||
// bodyId/bodyValid/velocity 保持默认(对账重建)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user