2 registered members (AndrewAMD, Quad),
748
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: clear vector()'s
[Re: Superku]
#393505
02/04/12 11:11
02/04/12 11:11
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
If you use a function like this:
VECTOR* vec_setxyz (VECTOR* v, float x, float y, float z)
{
if (v)
{
v->x = x;
v->y = y;
v->z = z;
return(v);
}
else
return(NULL);
}
You can simply do this and don't have to rely on vector(..):
int myLittleFunction ()
{
...
VECTOR v;
vec_setxyz(&v, 1, 2, 3);
draw_point3d(&v, COLOR_RED, 100, 23);
...
}
Since this is an engine-dll function, I don't understand why there is no std::vector<VECTOR*> used or the like and if in one frame the number of vector(...) calls exceeds the current used VECTOR*'s, new VECTOR*'s are generated and thrown into the std::vector... just my oppinion.
|
|
|
Re: clear vector()'s
[Re: HeelX]
#393507
02/04/12 12:31
02/04/12 12:31
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
OP
Expert
|
OP
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
_vector_current = (_vector_current+1)%64; That's what I assumed too, but after 64 draw calls (using vector()) the draw function receives odd values. VECTOR* vec_setxyz (VECTOR* v, float x, float y, float z) Hm yeah splitting stuff to a separate function at least solves the problem, although now I'm not entirely sure why.
draw_line3d( vec_add( vec_rotate( vec_create( vecTemp, -4, -4, 0 ), vec_create( vecTemp, angle, 0, 0) ), pos ), vec_create( vecTemp, 100,100,100), 100 );
After 64 draw_lin3d calls, the position is screwed up here. But why? VECTOR* rotate_point( VECTOR* relativePosition, VECTOR* absolutePosition, VECTOR* angle ) { vec_rotate( relativePosition, angle ); vec_add( relativePosition, absolutePosition ); return relativePosition; }
draw_line3d( rotate_point( vector(-4, -4, 0 ), vPos, vAngle ), vector( 100,100,100), 100 );
Now it works also above 64 draw calls. So why didn't the former approach work?
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
|