# GetDynamicMeshElements() : Need HELP

**URL:** <https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [March 11, 2015, 1:40am UTC](https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420 "2015-03-11T01:40:19Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![echoform](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@echoform](https://forums.unrealengine.com/u/echoform)\
**Post date:** [March 11, 2015, 1:40am UTC](https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420/1 "2015-03-11T01:40:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kamrann](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kamrann](https://forums.unrealengine.com/u/kamrann)\
**Post date:** [March 11, 2015, 11:33am UTC](https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420/2 "2015-03-11T11:33:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![echoform](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@echoform](https://forums.unrealengine.com/u/echoform)\
**Post date:** [March 11, 2015, 9:42pm UTC](https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420/3 "2015-03-11T21:42:07Z")

</div>

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…?

---

<div class="post-metadata">

**Author:** ![kamrann](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kamrann](https://forums.unrealengine.com/u/kamrann)\
**Post date:** [March 11, 2015, 9:51pm UTC](https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420/4 "2015-03-11T21:51:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![echoform](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@echoform](https://forums.unrealengine.com/u/echoform)\
**Post date:** [March 11, 2015, 10:13pm UTC](https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420/5 "2015-03-11T22:13:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kamrann](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kamrann](https://forums.unrealengine.com/u/kamrann)\
**Post date:** [March 11, 2015, 10:30pm UTC](https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420/6 "2015-03-11T22:30:10Z")

</div>

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);
```

---

<div class="post-metadata">

**Author:** ![echoform](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@echoform](https://forums.unrealengine.com/u/echoform)\
**Post date:** [March 11, 2015, 10:42pm UTC](https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420/7 "2015-03-11T22:42:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kamrann](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kamrann](https://forums.unrealengine.com/u/kamrann)\
**Post date:** [March 11, 2015, 10:53pm UTC](https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420/8 "2015-03-11T22:53:10Z")

</div>

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](https://github.com/volumesoffun/cubiquity-for-unreal-engine/commit/2a81df4b) 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.

---

<div class="post-metadata">

**Author:** ![echoform](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@echoform](https://forums.unrealengine.com/u/echoform)\
**Post date:** [March 11, 2015, 10:55pm UTC](https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420/9 "2015-03-11T22:55:57Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![kamrann](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kamrann](https://forums.unrealengine.com/u/kamrann)\
**Post date:** [March 11, 2015, 11:02pm UTC](https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420/10 "2015-03-11T23:02:00Z")

</div>

Ah okay, I wasn’t aware of that. Yeah there’s a note about it [here](http://wiki.popcornfx.com/index.php/UE4/Performance).  
No worries, glad you’ve made progress.

---

<div class="post-metadata">

**Author:** ![echoform](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@echoform](https://forums.unrealengine.com/u/echoform)\
**Post date:** [March 11, 2015, 11:10pm UTC](https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420/11 "2015-03-11T23:10:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kamrann](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kamrann](https://forums.unrealengine.com/u/kamrann)\
**Post date:** [March 11, 2015, 11:15pm UTC](https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420/12 "2015-03-11T23:15:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [March 12, 2015, 12:09am UTC](https://forums.unrealengine.com/t/getdynamicmeshelements-need-help/310420/13 "2015-03-12T00:09:55Z")

</div>

#Additional Code

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

> **[4.7 C++ Transition Guide](https://forums.unrealengine.com/showthread.php?59962-4-7-C-Transition-Guide&p=242403&viewfull=1#post242403)**
>
> Dear Community, Here is a thread where we can all compare our notes as we upgrade projects to 4.7! Please post the compile errors you encountered and then resolved to help others along! Also you are welcome to post questions here about compile...

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;
					}
```
