Download

Apex Memory problems

Hi Forum,

I am working on Apex, my final goal is move each chunk of geometry to whatever location, but not in runtime, just inside the editor via ConstructScript, something like the DestructibleMesh Editor explode slider,
to be honest I just highjack the portion of code and I create a new function inside my custom DestructibleMeshComponent, but for some reason every time I moved the chunks my memory RAM starts to fill exponentially, besides my update is slower in comparition. Perhaps they are using threads, I start by read everything inside the source code, but is a lot.

it is working fine, just with that 2 exceptions, slower update and Memory consumption.
this is my code:



void UIDSDestructibleMesh::setChunkTransform(FTransform InTransform, float ExplodeAmount)
{
#if WITH_APEX
	UDestructibleMesh* DMesh = GetDestructibleMesh();

	if (DMesh != NULL  && DMesh->ApexDestructibleAsset != NULL && DMesh->FractureSettings != NULL && this->IsRegistered())
	{
		if (DMesh->ApexDestructibleAsset->getRenderMeshAsset() != NULL)
		{
			if (DMesh->ApexDestructibleAsset->getPartIndex(0) < DMesh->ApexDestructibleAsset->getRenderMeshAsset()->getPartCount())
			{
				const PxBounds3& Level0Bounds = DMesh->ApexDestructibleAsset->getRenderMeshAsset()->getBounds(DMesh->ApexDestructibleAsset->getPartIndex(0));
				const PxVec3 Level0Center = !Level0Bounds.isEmpty() ? Level0Bounds.getCenter() : PxVec3(0.0f);
				for (uint32 ChunkIndex = 0; ChunkIndex < DMesh->ApexDestructibleAsset->getChunkCount(); ++ChunkIndex)
				{
					const uint32 PartIndex = DMesh->ApexDestructibleAsset->getPartIndex(ChunkIndex);

					if (PartIndex >= DMesh->ApexDestructibleAsset->getRenderMeshAsset()->getPartCount())
					{
						UE_LOG(LogTemp, Warning, TEXT("Screw"));
						continue;
					}

					uint32 ChunkDepth = 0;
					for (int32 ParentIndex = DMesh->ApexDestructibleAsset->getChunkParentIndex(ChunkIndex);
						ParentIndex >= 0;
						ParentIndex = DMesh->ApexDestructibleAsset->getChunkParentIndex(ParentIndex))
					{
						++ChunkDepth;
					}

					//const bool bChunkVisible = ChunkDepth == PreviewDepth;
					const bool bChunkVisible = true;
					this->SetChunkVisible(ChunkIndex, bChunkVisible);
					if (ChunkIndex == 0)
					{
						this->SetChunkVisible(ChunkIndex, false);
					}

					if (bChunkVisible)
					{
						UE_LOG(LogTemp, Warning, TEXT("yes"));
						const PxBounds3& ChunkBounds = DMesh->ApexDestructibleAsset->getRenderMeshAsset()->getBounds(PartIndex);
						const PxVec3 ChunkCenter = !ChunkBounds.isEmpty() ? ChunkBounds.getCenter() : PxVec3(0.0f);
						const PxVec3 Displacement = ExplodeAmount*(ChunkCenter - Level0Center);
						FRotator rotation = FRotator(90, 0, 0);
						//this->SetChunkWorldRT(ChunkIndex, FQuat(0.0f, 0.0f, 0.0f, 1.0f), P2UVector(Displacement));
						FVector naturalPos = P2UVector(Displacement);
						FVector finalPos = naturalPos + InTransform.GetLocation();
						this->SetChunkWorldRT(ChunkIndex, FQuat(0.0f, 0.0f, 0.0f, 1.0f), finalPos);
					}
				}
				this->BoundsScale = 100;
				this->UpdateComponentToWorld();
				this->DoDeferredRenderUpdates_Concurrent();
			}
		}
	}
#endif
}



some guru might help me please

Ok, I found my error, for some reason my Log remains in memory, and I have not idea why, the problem is just this simple line: UE_LOG(LogTemp, Warning, TEXT(“yes”));, is flooding my memory, the debug tools betrayed me this time,

but my question become more interesting, anybody now whats happen? why is this happening?