per-mesh 引用:MeshRendererComponent.meshIndex(-1=整模型)贯穿渲染收集/物理 Mesh 碰撞(自动跟随)/场景序列化(缺省键向前兼容)/Inspector mesh 下拉
This commit is contained in:
@@ -767,8 +767,14 @@ namespace Engine {
|
||||
// 动态/运动体 → ConvexHull(MeshShape 三角网格太贵,Jolt 不允许动)
|
||||
if (rb.type != ECS::RigidBodyComponent::BodyType::Static) {
|
||||
JPH::ConvexHullShapeSettings cs;
|
||||
for (const auto &mesh: model->GetMeshes()) {
|
||||
for (const auto &p: mesh->GetCpuPositions()) {
|
||||
const auto &meshes = model->GetMeshes();
|
||||
for (size_t mi = 0; mi < meshes.size(); ++mi) {
|
||||
// 单 mesh 子引用:碰撞只取渲染可见的同一 mesh(语义跟随)
|
||||
if (mc->meshIndex >= 0 &&
|
||||
static_cast<int>(mi) != mc->meshIndex) {
|
||||
continue;
|
||||
}
|
||||
for (const auto &p: meshes[mi]->GetCpuPositions()) {
|
||||
cs.mPoints.emplace_back(p.x * s.x, p.y * s.y, p.z * s.z);
|
||||
}
|
||||
}
|
||||
@@ -788,9 +794,15 @@ namespace Engine {
|
||||
JPH::VertexList verts;
|
||||
JPH::IndexedTriangleList tris;
|
||||
u32 base = 0;
|
||||
for (const auto &mesh: model->GetMeshes()) {
|
||||
const auto &pos = mesh->GetCpuPositions();
|
||||
const auto &idx = mesh->GetCpuIndices();
|
||||
const auto &meshes = model->GetMeshes();
|
||||
for (size_t mi = 0; mi < meshes.size(); ++mi) {
|
||||
// 单 mesh 子引用:碰撞只取渲染可见的同一 mesh(语义跟随)
|
||||
if (mc->meshIndex >= 0 &&
|
||||
static_cast<int>(mi) != mc->meshIndex) {
|
||||
continue;
|
||||
}
|
||||
const auto &pos = meshes[mi]->GetCpuPositions();
|
||||
const auto &idx = meshes[mi]->GetCpuIndices();
|
||||
verts.reserve(verts.size() + pos.size());
|
||||
for (const auto &p: pos) {
|
||||
verts.push_back(JPH::Float3(p.x * s.x, p.y * s.y, p.z * s.z));
|
||||
|
||||
Reference in New Issue
Block a user