コード例 #1
0
Compound* Actor::createCompoundFromChunk(const destructible::DestructibleActorImpl& actor, uint32_t partIndex)
{
	Mesh RTmesh;
	RTmesh.loadFromRenderMesh(*actor.getDestructibleAsset()->getRenderMeshAsset(),partIndex);

	// Fix texture v's (different between right hand and left hand)
	RTmesh.flipV();
	
	PxTransform pose(actor.getChunkPose(partIndex));
	pose.p = actor.getStructure()->getChunkWorldCentroid(actor.getChunk(partIndex));

	Compound* c = createCompound();

	c->createFromMesh(&RTmesh,pose,actor.getChunkLinearVelocity(partIndex),actor.getChunkAngularVelocity(partIndex),-1,actor.getScale());

	const DestructibleActorParamNS::BehaviorGroup_Type& behaviorGroup = actor.getBehaviorGroup(partIndex);
	mMinRadius = behaviorGroup.damageSpread.minimumRadius;
	mRadiusMultiplier = behaviorGroup.damageSpread.radiusMultiplier;

	// attachment
	//const DestructibleActorParamNS::RuntimeFracture_Type& params = mActor->getParams()->destructibleParameters.runtimeFracture;
	DestructibleParameters& params = mActor->getDestructibleParameters();
	mAttachmentFlags.posX |= params.rtFractureParameters.attachment.posX;
	mAttachmentFlags.negX |= params.rtFractureParameters.attachment.negX;
	mAttachmentFlags.posY |= params.rtFractureParameters.attachment.posY;
	mAttachmentFlags.negY |= params.rtFractureParameters.attachment.negY;
	mAttachmentFlags.posZ |= params.rtFractureParameters.attachment.posZ;
	mAttachmentFlags.negZ |= params.rtFractureParameters.attachment.negZ;

	attachBasedOnFlags(c);

	mRenderResourcesDirty = true;

	return c;
}