|
Re: is Vector must be ptr_remove?
[Re: frankjiang]
#470658
01/29/18 07:12
01/29/18 07:12
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
No, vector() returns a temporary vector, which means, it cycles through 64 pre-created vectors and returns a pointer to one of them (round robin style) so if you remove a vector, you will most likely get a crash, but even if not, you won't get predictable behaviour and bugs one cannot comprehend the function most likely looks something like this:
VECTOR storage[64];
int index = 0;
VECTOR * vector(var x, var y, var z)
{
VECTOR * vec = &storage[index];
index += 1;
if(index >= 64)
index = 0;
vec->x = x;
vec->y = y;
vec->z = z;
return vec;
}
|
|
|
Re: is Vector must be ptr_remove?
[Re: MasterQ32]
#470659
01/29/18 07:24
01/29/18 07:24
|
Joined: Dec 2009
Posts: 128 China
frankjiang
OP
Member
|
OP
Member
Joined: Dec 2009
Posts: 128
China
|
No, vector() returns a temporary vector, which means, it cycles through 64 pre-created vectors and returns a pointer to one of them (round robin style) so if you remove a vector, you will most likely get a crash, but even if not, you won't get predictable behaviour and bugs one cannot comprehend the function most likely looks something like this:
VECTOR storage[64];
int index = 0;
VECTOR * vector(var x, var y, var z)
{
VECTOR * vec = &storage[index];
index += 1;
if(index >= 64)
index = 0;
vec->x = x;
vec->y = y;
vec->z = z;
return vec;
}
so your means is not need to ptr_remove?
development 3d game is interesting!
|
|
|
Re: is Vector must be ptr_remove?
[Re: MasterQ32]
#470686
01/30/18 13:10
01/30/18 13:10
|
Joined: Dec 2009
Posts: 128 China
frankjiang
OP
Member
|
OP
Member
Joined: Dec 2009
Posts: 128
China
|
Ok ,i see,thank for your answer.
development 3d game is interesting!
|
|
|
|