Jump to content
  • Advertisement
Sign in to follow this  
3dnewbie

Please help

This topic is 4285 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can anyone help me solve this problem? It first resize to 2^2 but then the other statement raises it again ad infinitum Do i need to change the criteria? What is the best method for this ? /* Check here if we need to resize the grid */ if(object_count>1) { if(((grid_size*grid_size)/object_count<2) { grid_size+=1; fprintf(stderr,"Increasing: grid_size:%d [%d]\n",grid_size*grid_size,grid_size); /* Reset collisions */ collisions=0; } else if((grid_size*grid_size)/object_count/collisions>2) { grid_size-=1.0; fprintf(stderr,"Decreasing: grid_size:%d [%d]\n",grid_size*grid_size,grid_size); while(tmp!=NULL) { free(tmp->x); free(tmp->y); free(tmp->z); assign_coordinate(tmp); tmp=tmp->next;} } }

Share this post


Link to post
Share on other sites
Advertisement
It might help if you tell us what problem you're trying to solve. [wink]

What should that snippet of code do if it were functioning correctly? What (if anything) does it do now? Looks like it's something to do with resizing a grid, but if you can tell us exactly what's supposed to be going on we'll probably be better able to offer suggestions.

Share this post


Link to post
Share on other sites
Yes i'm trying to resize a grid accordingly to how many objects there are. It's a 2d grid in 3d space.
I a) need a simple formula to calculate this
and b) need to fix this problem

So the grid is 45^2, if i have 3 objects, it would be way to large so i downsize it. Vice versa the other
way around. Currently it first downsize to 2^2, which is ok, but then the other if statement kicks in
en increases it again, so from 2^2 to 2^3 and then it goes from 2^3 to 2^2 again, a loop so to speak.

I also am not to happy with the current formula for determining when to enlarge or make it smaller.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!