x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Drawing debug lines to persona viewport from AnimNode

So I've been still wrestling with the SkelControl bone rotation issue I asked about in this question , and I figured that at the very least being able to draw the calculated rotation axis to the viewport would help me in debugging the issue. Is it possible for me to access the viewport and draw some debugging lines, etc, to it, from inside my custom AnimNode/SkelControl? If so, where should I look in the documentation to find out how?

Edit: So, I found

void UAnimGraphNode_SkeletalControlBase::Draw( FPrimitiveDrawInterface* PDI, USkeletalMeshComponent * PreviewSkelMeshComp ) const;

There's a caveat with that though. If I want to use it to draw data that's generated during EvaluateBoneTransforms() on my runtime node, I need to cache that data so that Draw() can pull it out. However the instance of my runtime node that is created inside the AnimGraph node

UPROPERTY(EditAnywhere, Category=Settings)

FAnimNode_Fabrik Node;

(as the documentation says I should), isn't the same as the instance that is actually running, when I look at it in the debugger; all the values I'm caching aren't present in the instance that Draw() can access. How should I be doing this instead?

Edit 2: More digging with the debugger shows that the constructor for my AnimGraphNode is being called at least 6 or 8 times during editor startup, as well as when I open the Anim Blueprint in the editor. I'm now even more confused.

Product Version: Not Selected
Tags:
more ▼

asked Mar 20 '14 at 04:34 AM in C++ Programming

avatar image

twiddle
1.5k 55 36 73

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Persona Viewport World?

Is the Persona Viewport a world you can determine?

If so then you can use

Draw Debug Line

with that UWorld()

more ▼

answered Mar 26 '14 at 05:33 AM

avatar image

Rama
10.6k 446 346 1088

avatar image twiddle Mar 26 '14 at 05:49 AM

So the persona Viewport is AnimationEditorViewportClient, which inherits from FViewportClient and that class has GetWorld() implemented. The issue is that each node in the graph (the editor class) has a secondary class responsible for the actual calculations of each node (a runtime class) and it is the runtime class that needs to be able to draw the information. However it doesn't have a reference to the Graph Node that is its parent, which makes sense because in runtime mode you wont have a parent graph node (the graph doesnt exist in the runtime context, just the editor context). The runtime class, which is a subclass of FAnimNode_SkeletalControlBase, doesn't know anything about the world it is in, it's just given skeletal data and told to update the bones it needs to.

So the issue is that I can confirm that the viewport has a world reference, but I cannot access the viewport from the runtime object, and while the editor node might be able to access the viewport, I cannot use it to pull the data from public variables on the runtime object, because the instance that the graph node has is not the instance actually performing the calculation.

avatar image Rama Mar 26 '14 at 07:35 AM

Initialize(const FAnimationInitializeContext & Context)

 UWorld * TheWorld = Context.AnimInstance->GetWorld();


I found a way to access the world context just fine in my Turn in Place Animation node, I have not fully updated it to UE4 though, but this is what worked in the Beta!

Entire Source Code

ull code here: https://wiki.unrealengine.com/Animation_Node,_Entire_Source_for_a_Turn_In_Place_Node

Excerpt

 void FAnimNode_VictoryTurnInPlace::Initialize(const FAnimationInitializeContext & Context) 
 {
     //Init the Inputs
     BasePose.Initialize(Context);
     TurnPose.Initialize(Context);
  
     //Get the Actor Owner
     OwningActor = Context.AnimInstance-> GetSkelMeshComponent()->GetOwner(); 
  
     //Editor or Game?
     UWorld * TheWorld = Context.AnimInstance->GetWorld();
     if (!TheWorld) return;
     //~~~~~~~~~~~~~~~~
  
     WorldIsGame = (TheWorld->WorldType == EWorldType::Game);
 }
avatar image twiddle Mar 26 '14 at 07:51 AM

This looks good. I'll give it a shot as soon as I have a chance to sit down with the code again - I'm a bit surprised I missed the GetWorld function as being accessible in the animation context as I did go looking there, but it looks like its defined fairly high up in the class hierarchy so I didn't look hard enough evidently. :) I will return to mark this as resolved once I've tested it.

avatar image Rama Mar 26 '14 at 07:51 AM

AnimNodeBase

It's now called AnimNodeBase, not AnimNode_Base

avatar image twiddle Mar 26 '14 at 07:52 AM

All good, its still AnimNode_Base in the codebase I'm using at present. But thanks for notifying me.

avatar image twiddle Mar 26 '14 at 10:19 AM

Caching the world reference in Initialize() and then calling DrawDebugLine() inside the EvaluateBoneTransforms() did the trick. Thanks :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question