To strange for me to explain

edited February 2012 in Help request
I made my own debug tool to see points in 2d space. I did by the way read in Box2D's manual about some sort of debug mode that could be activated with a function or something, is that implemented in orx? This is my function anyway:
// From .h
	static orxSTATUS orxFASTCALL PaintDot( const orxVECTOR *position, const orxCOLOR *color );

// From .cpp
orxSTATUS orxFASTCALL StandAlone::PaintDot( const orxVECTOR *position, const orxCOLOR *color )
{
	if( position == orxNULL || color == orxNULL )
	{
		orxLOG("Dots are null");
		return orxSTATUS_FAILURE;
	}
	
	orxOBJECT *pstDot1 = StandAlone::GetObjectByName( "Dot1" );
	orxObject_SetColor( pstDot1, color );
	orxObject_SetPosition( pstDot1, position );

    return orxSTATUS_SUCCESS;
}

then I call it like this..
// In a collision event...
orxVECTOR bodyPosition;
orxVECTOR bodySpeed;

orxBody_GetPosition( hRecipientBody, &bodyPosition );
orxBody_GetSpeed( hRecipientBody, &bodySpeed );

orxVector_Normalize(&bodySpeed, &bodySpeed);
orxVector_Mulf(&bodySpeed, &bodySpeed, orxFLOAT(10));
orxVector_Add(&bodySpeed, &bodySpeed, &bodyPosition);

orxCOLOR color;
orxVECTOR RGB;
orxVECTOR position;

orxVector_Copy(&position, &bodyPosition);
				
orxVector_Set(&RGB, orxFLOAT(100), orxFLOAT(100), orxFLOAT(0));
orxColor_SetRGB (&color, &RGB);

PaintDot( &bodyPosition, &color );

This code works perfectly but if I comment out
orxVector_Copy(&position, &bodyPosition);
I can't see a the dot anywhere, how is that at all possible?

//AlgoJerViA

Comments

  • edited February 2012
    Hi,

    I don't see the problem. Weird.

    Did you try to set a breakpoint, assert, or some debug trace ?

    Do you have same problem in Debug and Release ?
  • edited February 2012
    Mmh, weird indeed!

    Which compiler/OS are you using? As faistoiplaisir said, does it work in debug? Have you had a look at the disassembly when the copy function is there or not to see if there's any difference?

    Otherwise for you question about Box2D debug rendering it's not implemented in orx as orx itself doesn't allow direct drawing.

    I guess I could add this feature or at least implement a Box2D debug draw directly in the Box2D plugin in OpenGL, the issue being that the Box2D plugin isn't aware of the cameras (for the world->screen transformation) nor if a camera is used by more than one viewport.

    I need to think a bit more on how to make this work in all cases but that would definitely a great tool to have.
  • edited February 2012
    I did not save the current code since it was rely not that big of a problem but more made feel that I didn't understand what was going on. I have since then completely rewritten everything from scratch but I will soon be back in the same situation and see if it comes up again.
  • edited February 2012
    Let us know if you encounter the same issue again. I'll try to add primitive drawing functions + Box2D debug rendering by the end of the week if I don't need to spend too much time at work as we recently entered beta.
  • edited February 2012
    Awesome!!! =)
  • edited February 2012
    Actually last night I added primitive drawing functions for line, polygons, boxes and circles (only on computers for now, the iOS/Android plugins don't have any implementation yet).

    Tonight I'll try to actually add the physics debug draw: I already plugged the logic with the config Physics.ShowDebug property, I just need to add the draw calls and add a centralized function to transform world coords into screen space on a per viewport basis.

    The drawback with the draw primitives is that they should happen between the start of the rendering pass and its end otherwise they won't display anything.

    There are events for that (orxRENDER_EVENT_START/_STOP) or people can even simply replace the rendering of a dummy object by their own code that would call them, in order to have them displayed as a certain "depth/layer".
  • edited February 2012
    The physics debug drawing is now on the SVN.

    It'll work in debug & profile modes only and will display all the debug shapes when the config property Physics.ShowDebug is set to true. (The property can be changed on-the-fly during execution.)

    Here's what it looks like:

    PhysicsDebug.png
Sign In or Register to comment.