GetDynamicMeshElements() : Need HELP

Hi,

I am trying to create a dynamic mesh creation by using

GetDynamicMeshElements().

I have a struct that is derived from FPrimitiveSceneProxy, Overriding virtual functions GetDynamicMeshElements() and GetViewRelevance() to turn on bDynamicRelevance to be true.

This FStruct’s instance will be returned from a virtual fucntion override for CreateSceneProxy() which is in a class that is derrived from UPrimitiveComponent.

I have this class that is derived from UPrimitiveComponent in my Actor derived class but the GetDynamicMeshElements() is not called…

I must have missed something, would there be any reference show how to use this property correctly?

Did you confirm through the debugger that your render proxy is actually being created? If it’s not it may be that your component or its parent actor is set to be not visible.

If it is being created but the GetDynamicMeshElements method is not called, it would appear to be related to GetViewRelevance, or maybe CalculateBounds.

There are loads of examples of this in the engine source code. Look at, for example, FDebugRenderSceneProxy.

The render proxy seems to be generated if I step through debugger because,

CreateSceneProxy() for is called and it was calling below

return new FJumpPadRenderingProxy(this);

that is derived from FPrimitiveSceneProxy

This is what I have for the derived class

	FPrimitiveViewRelevance GetViewRelevance(const FSceneView* View)
	{
		FPrimitiveViewRelevance Result;
		Result.bDrawRelevance = IsShown(View) && (IsSelected() || View->Family->EngineShowFlags.Navigation);
		Result.bDynamicRelevance = true;
		Result.bNormalTranslucencyRelevance = IsShown(View);
		Result.bShadowRelevance = IsShadowCast(View);
		Result.bEditorPrimitiveRelevance = UseEditorCompositing(View);
		return Result;
	}

, so it has Result.bDynamicRelevance = true;
am I missing something else…?

Result.bDrawRelevance = IsShown(View) && (IsSelected() || View->Family->EngineShowFlags.Navigation);
This is set up to only draw if the component is selected, or if navigation visualisation is selected in the viewport’s ‘Show’ menu. Could that be the problem or is this intentional?

CalcBounds() is not called but GetViewRelevance() is called and Result.bDynamicRelevance = true;

Yes, but I think bDrawRelevance will override bDynamicRelevance, and currently that will be set to false in the conditions I mentioned above.
Try using just

Result.bDrawRelevance = IsShown(View);

I tried it and even Result.bDynamicRelevance = true; but it still seems to not load it… I am using 4.5.1 and they say that GetDynamicMeshElements is not used for default path. I have to turn on something in DefaultEngine.ini but the parameter is not given. I don’t know which parameter to switch that on. or else.

Ah okay, I was assuming you were using the latest version. I’m not certain, but I believe pre 4.7 you may want to override DrawDynamicElements rather than GetDynamicMeshElements.

This link which someone posted in the 4.7 transition thread may be useful to you. It shows an example of the differences in implementing this behaviour pre and post 4.7.

If I toggle r.UseGetDynamicMeshElements 1, it seems to be visible in editor, I have to see this in game as well. Well, at least I am on the right way. Thanks Kamrann!

Ah okay, I wasn’t aware of that. Yeah there’s a note about it here.
No worries, glad you’ve made progress.

Try adding to ConsoleVariables.ini an extra line r.UseGetDynamicMeshElements=1 was it! thanks!

Great. Remember to remark the question as answered - it gets reset when you add a further comment. Cheers!

#Additional Code

I also post how to get the PDI without DrawDynamicMeshElements in my Transition guide here:

Code:

FPrimitiveSceneProxy* UJoyDrawComp::CreateSceneProxy()
{
	class JoyDrawSceneProxy : public FPrimitiveSceneProxy
	{
	public:
		JoyDrawSceneProxy(UJoyDrawComp* InComponent)
			:	FPrimitiveSceneProxy(InComponent),
				JoyDraw(InComponent)
		{
			bWillEverBeLit = false;
		}

		//Draw Dynamic Elements is not used any more
		virtual void GetDynamicMeshElements(
			const TArray<const FSceneView*>& Views, 
			const FSceneViewFamily& ViewFamily, 
			uint32 VisibilityMap, 
			class FMeshElementCollector& Collector
		) const override
		{   
			//See SphereComponent.cpp for reference
			for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
			{
				if (VisibilityMap & (1 << ViewIndex))
				{
					const FSceneView* View = Views[ViewIndex];
					FPrimitiveDrawInterface* PDI = Collector.GetPDI(ViewIndex);
					if(!PDI)
					{
						continue;
					}