Page 3 of 3 FirstFirst 123
Results 31 to 45 of 45

Thread: How do I start the debugger from a .p file?

  1. #31
    In the specular_node example that I'm using as a template the load function looks like that with the break; outside of it. I moved it inside like you said but than it stops reading all values like it did before. It just reads the first one and jumps to the bottom.
    If I search in the lws file the correct values are there.
    When I write float fval = 0,0; the value is 0 after loading so it seem there is something wrong with the way I load things.

    This is the save function:

    XCALL_(static LWError)
    Save(LWInstance instance, const LWSaveState *save)
    {
    Trigger_p inst = (Trigger_p)instance;


    LWSAVE_BEGIN(save, &Trigg_Block[0], 1);
    {
    float fval = (float)inst->v_trigg;
    LWSAVE_FP(save, &fval, 1);
    }
    LWSAVE_END(save);

    LWSAVE_BEGIN(save, &Trigg_Block[1], 1);
    {
    float fval = (float)inst->v_swi;
    LWSAVE_FP(save, &fval, 1);
    }
    LWSAVE_END(save);

    LWSAVE_BEGIN(save, &Trigg_Block[2], 1);
    {
    float fval = (float)inst->v_switchedAtFrame;
    LWSAVE_FP(save, &fval, 1);
    }
    LWSAVE_END(save);

    LWSAVE_BEGIN(save, &Trigg_Block[3], 1);
    {
    float fval = (float)inst->v_storedValue;
    LWSAVE_FP(save, &fval, 1);
    }
    LWSAVE_END(save);

    return NULL;
    }
    Last edited by Every4thPixel; 01-16-2017 at 07:57 AM.

  2. #32
    I found the error .
    In the names below I had used spaces and it turns out that's not allowed. I thought it was just a string so I could use spaces. Now the values read correctly.
    static LWBlockIdent Trigg_Block[] = {

    ID_TR_TRIGG, "Trigger",
    ID_TR_SWI, "Switch",
    ID_TR_SLV, "Stored value",
    ID_TR_SWIAT, "Switched at frame",
    0
    };

  3. #33
    It also turns out the trigger node renders on LWSN. I'll post it here but first I'll test it myself some more.

  4. #34

  5. #35
    I've got a new problem YAY! I've got my node that has one output. Now I want to add an other output that puts out a second value. How do I do that. It tried :

    outputfuncs->next;
    outputfuncs->setValue(Value, frameOffsetArr);
    outputfuncs->first;

    This doesn't work because now all the outputs share the same value.
    I've created 2 NodeOutputID's called output and output2. That correct right?
    Like this:
    inst->output = outputfuncs->create(node, NOT_VECTOR, "Triggered");
    inst->output2 = outputfuncs->create(node, NOT_SCALAR, "Frame Offset");

    What happens exactly when you do outputfuncs->next;? Does the whole evaluate function start over? Why can't a just assign a value to my output variable in this case output2?

    I shouldn't do this should I? (I mean adding "NodeValue Value2"):
    XCALL_(static void)
    Evaluate(void *data, LWNodalAccess *na, NodeOutputID out, NodeValue Value, NodeValue Value2)
    {

    No matter what I do both outputs share the same value. What am I doing wrong?
    Should I create an evaluate function for every output?

    EDIT: I think I get it. That last thing worked.

    I do have an other question: Both my output are putting out a value but one of them only works when the node editor is open. What could that be?
    Last edited by Every4thPixel; 02-01-2017 at 01:07 PM.

  6. #36
    Both my outputs are putting out a value but my second one only works when the node editor is open or when the first one is connected as well. What could that be?

  7. #37
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,876
    If I have more than one output:
    Code:
    XCALL_( void )
    Evaluate(
     LWInstance instance,
     LWNodalAccess *nodalaccess,
     NodeOutputID nodeoutputid,
     NodeValue nodevalue )
    {
    	Data *data = (Data *) instance;
    	if( nodeoutputid == data->m_NodeOutputID_1 )
    	{
                    int result = 1;
    		data->m_NodeOutputFuncs->setValue( nodevalue, &result );
    	}
    	else if( nodeoutputid == data->m_NodeOutputID_2 )
    	{
                    int result = 2;
    		data->m_NodeOutputFuncs->setValue( nodevalue, &result );
    	}
    	else if( nodeoutputid == data->m_NodeOutputID_3 )
    	{
                    int result = 3;
    		data->m_NodeOutputFuncs->setValue( nodevalue, &result );
    	}
    }
    (all scalars in example)
    Last edited by Sensei; 02-01-2017 at 02:45 PM.

  8. #38
    Thanks Sensei! That works even better! I now added an option that enables you to trigger animation curves. It's really fun to play with

  9. #39
    I've got a new one for you! I'm trying to make my expanded node work on LWSN. I stored some values in an LWS file but when I load them back in they are overwritten by something in the evaluate function. I tried to use if(sceneinfo->loadInProgress == 0) and if (sceneinfo->rendermode == lwrm_None) but this doesn's seem to change anything. Everything below these if statements gets executed even when LW loads the scene. Is there a better way that works so I'm able to keep my values?

    An other question derived from this problem.
    Why is LW executing the evaluate function so many times on load? It seem to read every thing at least twice?

  10. #40
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,876
    Evaluate() of which node "type".. ?

    If node is used in Surface Node Editor, it's called by preview area, when Surface Editor is turned on, and there is displayed preview..
    Also it'll be called by VPR, if VPR is enabled.

    In Evalute() you cannot change instance data, without good reason.
    It's called from multi-threads.
    So, if you really really have to, you must surround it by mutex lock/unlock. This could be serious issue for speed of execution or even future source of deadlocks.
    I doubt you really have to do it..
    I never had to in any my node store data from Evaluate() in instance data, AFAIR.

    LWSceneInfo must be acquired every time you need it read from it by GlobalFunc, AFAIK.
    Last edited by Sensei; 02-10-2017 at 10:36 AM.

  11. #41
    I'm using the node now to trigger a motion curve in the nodal motion editor.
    This different behavior in node editor type is a good lead to indicate where the problem lies I think. In the displacement editor it does work but in the nodal motion it doesn't. Does this mean I can assign values to instance data in the nodal displacement editor but not in the nodal motion editor? Because I think I am actually changing instanced data in evaluate. So you are saying things like this inst->v_frameOffset = timeinfo->frame; are not possible or am I misunderstanding what you mean?

  12. #42
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,876
    In Evaluate() you have input parameter LWInstance instdata or so,
    you don't modify it....
    I can't think of situation when you need to modify LWInstance from Evaluate()..

    Evaluate() can be called by Surface Editor previewing routine, by VPR routine, by regular renderer routine, by LWSN..
    Some of them from multiple threads,
    some of them mixed each other..
    You can get Evaluate() from preview, from VPR, and F9, nearly parallel..

  13. #43
    Isn't one situation when you would want to modify instdata one where you would store an input value or when you want to cache something?

    So this snippet down here is a bad idea or not possible you are saying?

    XCALL_(static void)
    Evaluate(void *data, LWNodalAccess *na, NodeOutputID out, NodeValue Value)
    {
    Trigger_p inst = (Trigger_p)data;

    inst->v_frameOffset = 0;

  14. #44
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,876
    Quote Originally Posted by Every4thPixel View Post
    Isn't one situation when you would want to modify instdata one where you would store an input value or when you want to cache something?
    Ah, right. Cache (per-pixel, per-3d vertex), is example when you want to modify instance data.
    But you can forget about using it in LWSN, random frame F10, render queue, etc.
    without making baking functionality (store cache in external file, which LWSN (inside of Evaluate()) will just read (so again Evaluate() won't be storing anything)).

    Quote Originally Posted by Every4thPixel View Post
    So this snippet down here is a bad idea or not possible you are saying?
    Yes, because it does not bother about different rendering states (preview/VPR/full render), and does not bother about multi-tasking...

    Node learns which mode it's in, inside of Init( int mode )
    LWINIT_PREVIEW,
    LWINIT_RENDER

    Imagine:
    1st render node in LWSN mode is rendering frame 1, NewFrame() receives LWFrame/LWTime for 1st frame,
    2nd node in LWSN mode is rendering frame 2, NewFrame() receives LWFrame/LWTime for 2nd frame,
    3rd node in LWSN mode is rendering frame 3, NewFrame() receives LWFrame/LWTime for 3rd frame,
    (....)
    n-th node in LWSN mode is rendering frame n, NewFrame() receives LWFrame/LWTime for n-th frame,
    This will happen simultaneously (or close to it)...
    Render nodes don't communicate to each other machine..

    What does this line anyway?
    v_frameOffset = 0;
    Where is used v_frameOffset later.. ?


    Evaluate() can be called from multiple threads at the same time,
    thread 1st is calling it, there is context-switch,
    or 2nd core is calling Evaluate(),
    and thread 2nd is calling it...
    How can they both set v_frameOffset to 0?
    If 1st set it, then f.e. incremented,
    and 2nd thread will set it again to 0..
    It'll be complete mess.
    Last edited by Sensei; 02-12-2017 at 03:32 PM.

  15. #45
    Quote Originally Posted by Sensei View Post
    Ah, right. Cache (per-pixel, per-3d vertex), is example when you want to modify instance data.
    But you can forget about using it in LWSN, random frame F10, render queue, etc.
    without making baking functionality (store cache in external file, which LWSN (inside of Evaluate()) will just read (so again Evaluate() won't be storing anything)).
    That's why I was storing a bool to check if this node was triggered so I could skip the part of code that resets all the stored values. Because it only resets on frames where it wasn't triggered it actually worked.


    Quote Originally Posted by Sensei View Post

    Yes, because it does not bother about different rendering states (preview/VPR/full render), and does not bother about multi-tasking...
    Ah crap.

    Quote Originally Posted by Sensei View Post
    Node learns which mode it's in, inside of Init( int mode )
    LWINIT_PREVIEW,
    LWINIT_RENDER


    Imagine:
    1st render node in LWSN mode is rendering frame 1, NewFrame() receives LWFrame/LWTime for 1st frame,
    2nd node in LWSN mode is rendering frame 2, NewFrame() receives LWFrame/LWTime for 2nd frame,
    3rd node in LWSN mode is rendering frame 3, NewFrame() receives LWFrame/LWTime for 3rd frame,
    (....)
    n-th node in LWSN mode is rendering frame n, NewFrame() receives LWFrame/LWTime for n-th frame,
    This will happen simultaneously (or close to it)...
    Render nodes don't communicate to each other machine..
    I know that's why I'm storing the point in time the trigger happend. I can use that value later to load back in to the node while it renders on LWSN.

    Quote Originally Posted by Sensei View Post
    What does this line anyway?
    v_frameOffset = 0;
    Where is used v_frameOffset later.. ?
    I'm using that to zero out the reset point in time. For example when you change the animation and the nodes trigger condition is no longer true is resets.

    Quote Originally Posted by Sensei View Post
    Evaluate() can be called from multiple threads at the same time,
    thread 1st is calling it, there is context-switch,
    or 2nd core is calling Evaluate(),
    and thread 2nd is calling it...
    How can they both set v_frameOffset to 0?
    If 1st set it, then f.e. incremented,
    and 2nd thread will set it again to 0..
    It'll be complete mess.
    Ah yes that a big problem.

    Could this be a solution? I could create a function that scans all trigger nodes in the scene (or just one.) This function could be called by pressing a button in the node itself or outside of it.
    Just like dynamics and particles have their calculate button?

Page 3 of 3 FirstFirst 123

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •