Gamestudio Links
Zorro Links
Newest Posts
Fun Arcade Car Physics (nfs style)
by Ezzett. 08/02/26 21:11
ZorroGPT
by TipmyPip. 07/31/26 22:56
Wolfram Mathematica with Zorro
by TipmyPip. 07/30/26 02:07
What are you working on?
by rayp. 07/24/26 22:58
Z9 getting Error 058
by madpower2000. 07/22/26 14:01
New Zorro version 3.11
by jcl. 07/21/26 13:42
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 1,375 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
riggi89, shuhari, KD1990, Ephraim, Student_64151
19223 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
is Vector must be ptr_remove? #470657
01/29/18 06:22
01/29/18 06:22
Joined: Dec 2009
Posts: 128
China
frankjiang Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
Code:
VECTOR* tarPos = vector(x,y,0);
ptr_remove(tarPos);//is tarPos must be ptr_remove?any one know that?



development 3d game is interesting!
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 Offline
Expert
MasterQ32  Offline
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:

Code:
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;
}



Visit my site: www.masterq32.de
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 Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
Originally Posted By: MasterQ32
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:

Code:
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: frankjiang] #470678
01/30/18 07:06
01/30/18 07:06
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
yes, don't ptr_remove. if you do, your program will have horribly bad errors, most probably in other parts of your code


Visit my site: www.masterq32.de
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 Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
Ok ,i see,thank for your answer.


development 3d game is interesting!

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1