Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
768 B
1
Indexable
class UCustomISMC : public UInstancedStaticMeshComponent
{
	//
	void BeginBatchUpdate()
	{
		check(IsInGameThread());
	}


	void EndBatchUpdate(bool bMarkRenderStateDirty = false)
	{
		check(IsInGameThread());

		Modify();

		// Request navigation update - Execute on a single index as it updates everything anyway
		PartialNavigationUpdate(0);

		// Force recreation of the render data when proxy is created
		InstanceUpdateCmdBuffer.Edit();

		if (bMarkRenderStateDirty)
			MarkRenderStateDirty();
	}

	void UsamgeExample()
	{
		BeginBatchUpdate();
		
		ParallelFor(PerInstanceSMData.Num(), [=](int Index) {

			 this->PerInstanceSMData[Index].Transform.AddToTranslation(FVector(100, 0, 0));
		});
		
		EndBatchUpdate();
	}
};