• 多出来的 + 1?这里为什么多分配一个 PxVec3 呢? nbPrimitives+1
bool AABBTree::buildInit(AABBTreeBuildParams& params, BuildStats& stats)
{
	// Checkings
	const PxU32 nbPrimitives = params.mNbPrimitives;
	if(!nbPrimitives)
		return false;
	// Release previous tree
	release();
	// Init stats
	stats.setCount(1);
	// Initialize indices. This list will be modified during build.
	mNbIndices = nbPrimitives;
	mIndices = reinterpret_cast<PxU32*>(PX_ALLOC(sizeof(PxU32)*nbPrimitives, "AABB tree indices"));
	// Identity permutation
	for(PxU32 i=0;i<nbPrimitives;i++)
		mIndices[i] = i;
	// Allocate a pool of nodes
	mNodeAllocator.init(nbPrimitives, params.mLimit);
	// Compute box centers only once and cache them
	params.mCache = reinterpret_cast<PxVec3*>(PX_ALLOC(sizeof(PxVec3)*(nbPrimitives+1), "cache"));
	const float half = 0.5f;
	const FloatV halfV = FLoad(half);
	for(PxU32 i=0;i<nbPrimitives;i++)
	{
		const Vec4V curMinV = V4LoadU(&params.mAABBArray[i].minimum.x);
		const Vec4V curMaxV = V4LoadU(&params.mAABBArray[i].maximum.x);
		const Vec4V centerV = V4Scale(V4Add(curMaxV, curMinV), halfV);
		V4StoreU(centerV, &params.mCache[i].x);
	}
	return true;
}

为啥要用 Vec4 的接口来处理 Vec3 ?部分操作是 128 字节对齐例如 V4StoreU -> _mm_storeu_ps,另外这里参数还是反的比较有意思。

image-20220815171457393

image-20220815171506261

image-20220815171513528

SqExtendedBucketPruner.cpp 的 refitMarkedNodes 有问题:

image-20220901180739951

更新于 阅读次数

请我[恰饭]~( ̄▽ ̄)~*

鑫酱(●'◡'●) 微信支付

微信支付

鑫酱(●'◡'●) 支付宝

支付宝