Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Quad), 755 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
I think i need a quadtree but not sure how to make it #316841
03/27/10 04:25
03/27/10 04:25
Joined: Oct 2009
Posts: 110
Porto-Portugal
Elektron Offline OP
Member
Elektron  Offline OP
Member

Joined: Oct 2009
Posts: 110
Porto-Portugal
I am generating a forest.
I want next generated tree has distance X of all allready generated trees.
I am using vec_dist to generate map but is slow (500) trees
I donīt know if i should make my function calculating distance on 2d for speed up?
Or create a grid over map and only make collisition testing inside the cell?
Or maybe both?
I have the source of octree made on c++ , could be usefull translate to lite-c or the effort donīt pays and is faster to make from sctach?

Any advice or link are welcome.
Thanks in advance



Carlos Ribeiro aka Elektron
Check my blog: http://indiegamedeveloper71.wordpress.com/
Re: I think i need a quadtree but not sure how to make it [Re: Elektron] #317724
04/01/10 23:49
04/01/10 23:49
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

I saw some code in the Lite-c contributions done by Alan
This might be what your looking for.

Use the search and write tcmain.c


Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: I think i need a quadtree but not sure how to make it [Re: Ottawa] #317739
04/02/10 02:45
04/02/10 02:45
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
The algorithm of vec_dist is the following:
Originally Posted By: Manual
temp[0] = vektor1[0] - vektor2[0];
temp[1] = vektor1[1] - vektor2[1];
temp[2] = vektor1[2] - vektor2[2];
distance = sqrt(temp[0]*temp[0] + temp[1]*temp[1] + temp[2]*temp[2]);

That means it is really fast. There must be something different that slows your code/ game down, the fact that you create 500 entities at once should be the problem.
Immediately after creation set their passable flag, this will be much faster:

you = ent_create(tree...)
set(you,PASSABLE);


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: I think i need a quadtree but not sure how to make it [Re: Superku] #317781
04/02/10 14:41
04/02/10 14:41
Joined: Aug 2005
Posts: 1,230
M
MichaelGale Offline
Serious User
MichaelGale  Offline
Serious User
M

Joined: Aug 2005
Posts: 1,230
vec_dist is slow because it uses sqrt, especially when you have to use it many times per frame. If you want better speed, you could use the squared length (i.e. the same function as vec_dist but without the sqrt) to compare distances, although at the cost of accuracy on longer distances.


Your friendly mod is at your service.
Re: I think i need a quadtree but not sure how to make it [Re: MichaelGale] #317852
04/03/10 02:05
04/03/10 02:05
Joined: Oct 2009
Posts: 110
Porto-Portugal
Elektron Offline OP
Member
Elektron  Offline OP
Member

Joined: Oct 2009
Posts: 110
Porto-Portugal
Thank you all for your help.


Carlos Ribeiro aka Elektron
Check my blog: http://indiegamedeveloper71.wordpress.com/

Gamestudio download | chip programmers | 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