-----------------------------------------------------------------------------------------------
append mesh 用着有问题,mesh会变 有时候normal变了
用Boolean union模式就行 就是速度有点慢
---------------------------------------------------------------
ADynamicMeshActor里面自带一个pool
UDynamicMeshPool* ADynamicMeshActor::GetComputeMeshPool()
{
if (DynamicMeshPool == nullptr && bEnableComputeMeshPool)
{
DynamicMeshPool = NewObject<UDynamicMeshPool>();
}
return DynamicMeshPool;
}
UDynamicMesh* ADynamicMeshActor::AllocateComputeMesh()
{
if (bEnableComputeMeshPool)
{
UDynamicMeshPool* UsePool = GetComputeMeshPool();
if (UsePool)
{
return UsePool->RequestMesh();
}
}
// if we could not return a pool mesh, allocate a new mesh that isn't owned by the pool
return NewObject<UDynamicMesh>(this);
}
----------------------------------------------------------------------------------------------
在editor状态下
如果一个level A 用了 packed level instance B
那么A里面应该有一个packed level actor C 引用 B
在C中 有多个 instanced static mesh component
多少个 instanced static mesh component 代表B中多少种类的 static mesh actor
一个instanced static mesh component 代表 多个 同一种类的static mesh actor
如果packed level instance 有嵌套
比如A 中 有B B中有C
那么在editor 状况下 只要获得B对应的 packed level actor ,这个actor 其实 引擎已经帮你递归了, 这个actor已经包含了全部的static mesh actor 不管 里面嵌套多少层
---------------------------------------------------------------------
蓝图中生成一个dynamic mesh的方法
1、
记得维护这个pool 该释放释放
2、万能的
3、ADynamicMeshActor里面自带一个pool
UDynamicMeshPool* ADynamicMeshActor::GetComputeMeshPool()
{
if (DynamicMeshPool == nullptr && bEnableComputeMeshPool)
{
DynamicMeshPool = NewObject<UDynamicMeshPool>();
}
return DynamicMeshPool;
}
UDynamicMesh* ADynamicMeshActor::AllocateComputeMesh()
{
if (bEnableComputeMeshPool)
{
UDynamicMeshPool* UsePool = GetComputeMeshPool();
if (UsePool)
{
return UsePool->RequestMesh();
}
}
// if we could not return a pool mesh, allocate a new mesh that isn't owned by the pool
return NewObject<UDynamicMesh>(this);
}