Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
The_Frag_Man
Mar 26, 2005

md3 has some bones for aligning sub models, they are called tags I think. I used md2 for a while, but it has a problem that the vertex coordinates are compressed and the compression is lossy. I recommend MD3.

Adbot
ADBOT LOVES YOU

mewlink64
Apr 6, 2009
OK, so, I'm writing a game in COBOL(Yes, I hate happiness). I was wondering if anybody knew of any previous games that were written in COBOL. My instructor said that some students some time ago made like a tic-tac-toe game. What I'M doing, however, is a rougelike. It's the only feasible game that I think might be easily done in COBOL, plus I get to do graphics. So far I have the map displaying to the screen, and next I'm going to code in a search for the player and a player move.

As to why I'm doing this, if you've taken COBOL classes before, you probably understand how boring an hour and a half of it is twice a week. I'm just trying to apply my skills and do something entertaining at the same time.

Scarboy
Jan 31, 2001

Good Luck!
That sounds too interactive, you should print to a dot matrix printer after every move.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

The_Frag_Man posted:

md3 has some bones for aligning sub models, they are called tags I think. I used md2 for a while, but it has a problem that the vertex coordinates are compressed and the compression is lossy. I recommend MD3.
MD3 also has the problem that verts are stored as shorts and consequently have a hard limit on how large the model can be. There are obvious ways you can deal with this, but it's definitely a design issue to be aware of. :)

There isn't really a whole lot of reason to use it, skeletal animation opens up many more possibilities and the only drawback is you can't leech existing content as easily. Well, that and you have to figure out how to make it either not suck up all your CPU, or do the transforms in the vertex shader (do this).

OneEightHundred fucked around with this message at 08:24 on Apr 16, 2009

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I have an OpenGL question about vertex buffer objects. All the tutorials are dealing with a single buffer. They may be pulling vertices, normals, and other components from different buffers, but they're using them together. What I'm thinking instead is multiple buffers of vertices, normals, etc.

Right now I am trying to draw something from multiple buffers of triangle strips, with matching buffers of normals. When I draw it using vertex arrays, it does render correctly. I suspect I am screwing something up in how I go through the code. I don't have access to the exact code right now, but I can review my thought process here. If it seems correct then I can post the code tonight.

I'm writing in C, or rather procedural C++, if that means anything to you.
code:
GLFloat** vertices = // allocate and assign multiple GLFloat buffers of vertices
GLFloat** normals = // allocate and assigned multiple GLFloat buffers of normals

GLuint* vert_IDs = // store vertex vbo ID's
GLuint* norm_IDs = // store norm vbo ID's

for(int i = 0; i < number_of_buffers; i++) {
   // vertices
   glGenBuffer(1, vert_IDs[i]);
   glBindBuffer(GL_ARRAY_BUFFER_ARB, vert_IDs[i]);
   glBufferData(GL_ARRAY_BUFFER_ARB, sizeof(GLFloat) * 3 * vertex_count, vertices[i], GL_STATIC_DRAW_ARB);

   // normals
   glGenBuffer(1, norm_IDs[i]);
   glBindBuffer(GL_ARRAY_BUFFER_ARB, norm_IDs[i]);
   glBufferData(GL_ARRAY_BUFFER_ARB, sizeof(GLFloat) * 3 * vertex_count, normals[i], GL_STATIC_DRAW_ARB);
}


....
// Display code
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);	

for(int i = 0; i < number_of_buffers; i++) {
  glBindBufferARB(GL_ARRAY_BUFFER_ARB, vert_IDs[i]);
  glVertexPointer(3, GL_FLOAT, 0, 0);

  glBindBufferARB(GL_ARRAY_BUFFER_ARB, norm_IDs[i]);
  glNormalPointer(GL_FLOAT, 0, 0);

  glDrawArrays(GL_TRIANGLE_STRIP, 0, vertex_count);
}

glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );	

Something like that. I get deterministic garbage, like maybe it's drawing normals as vertices or something. The same code refactored to do vertex arrays--eliminating the vbo bindings and such--renders correctly.

Side note: I originally had the buffers interleaved, but tried to factor that out in case it was causing trouble. Again, that worked with vertex arrays, but not the vbos.

I assume I'm doing something bad with the OpenGL state machine. Say, maybe I need to unbind someplace either while loading or rendering, but I wouldn't know.

mewlink64
Apr 6, 2009

Scarboy posted:

That sounds too interactive, you should print to a dot matrix printer after every move.

I toyed with the notion, maybe in an advanced version as a joke. For now in the early stages, display screen only.

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH

OneEightHundred posted:

MD3 also has the problem that verts are stored as shorts and consequently have a hard limit on how large the model can be. There are obvious ways you can deal with this, but it's definitely a design issue to be aware of. :)

There isn't really a whole lot of reason to use it, skeletal animation opens up many more possibilities and the only drawback is you can't leech existing content as easily. Well, that and you have to figure out how to make it either not suck up all your CPU, or do the transforms in the vertex shader (do this).
The models will be relatively small and low poly count. This project won't really benefit from skeletal animations so I would really like to avoid implementing it. Are there any suggestions for other formats to use other than MD2 and MD3 that are simply a list of a set of verts for each animation keyframe? MD2 seems to be the best fit for this, no? I am even considering just coming up with our own format that is basically verts stripped from OBJ files of each keyframe appended together in a single file.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
e: Nevermind, read that wrong, not sure what's wrong with the draw buffers thing.

FYI though, you should consider a few optimizations:
- Keep all data in the same buffer if at all possible. Changing buffers is expensive, using a different location/stride in the same buffer is cheap.
- Use an index buffer and draw using glDrawRangeElements with GL_TRIANGLES as the mode

I hope you're not doing exactly this though:
code:
glGenBuffer(1, vert_IDs[i]);
... glGenBuffers takes a pointer, so it should be vert_IDs + i


supster posted:

The models will be relatively small and low poly count. This project won't really benefit from skeletal animations so I would really like to avoid implementing it. Are there any suggestions for other formats to use other than MD2 and MD3 that are simply a list of a set of verts for each animation keyframe? MD2 seems to be the best fit for this, no? I am even considering just coming up with our own format that is basically verts stripped from OBJ files of each keyframe appended together in a single file.
MD3 would be fine for that then.

OneEightHundred fucked around with this message at 06:51 on Apr 17, 2009

Contero
Mar 28, 2004

Are there any good website-based tutorials or information about BSP tree implementation? Yes I know about the collision detection book. I plan on buying it. I just need to give a friend of mine a place to start on the subject before I can get the book.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

OneEightHundred posted:

FYI though, you should consider a few optimizations:
- Keep all data in the same buffer if at all possible. Changing buffers is expensive, using a different location/stride in the same buffer is cheap.
- Use an index buffer and draw using glDrawRangeElements with GL_TRIANGLES as the mode

I hope you're not doing exactly this though:
code:
glGenBuffer(1, vert_IDs[i]);
... glGenBuffers takes a pointer, so it should be vert_IDs + i

MD3 would be fine for that then.
I think I was doing &(vert_IDs[i]). I just took an existing tutorial and started trying to manipulate it and ran into similar glitches so it seems that I screw it up from the point I specify the vertices. I'm trying to use triangle strips. Is there any fine print about using triangle strips with vbo's that one doesn't necessarily encounter with vertex arrays?

I originally was interleaved but unwound it all while trying to sort out why I was getting garbage. I thought it might have been rendering some of my normals as vertices in particular.

ehnus
Apr 16, 2003

Now you're thinking with portals!

Contero posted:

Are there any good website-based tutorials or information about BSP tree implementation? Yes I know about the collision detection book. I plan on buying it. I just need to give a friend of mine a place to start on the subject before I can get the book.


Michael Abrash's Graphics Programming Black Book has a couple chapters dedicated to BSP trees. It's kind of old but may be a decent place to start off with:

http://www.gamedev.net/reference/articles/article1698.asp

Check out chapters 59-62

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
The problem I was having had something to do with the buffer lengths I was specifying to the draw routines, so I got past that. The next thing I wanted to try was a pixel/fragment shader. Is Nvidia's Cg toolkit the accepted standard for developing shaders with OpenGL?

Bakkon
Jun 7, 2006

SQUIRTLE SQUAD
I've been taking programming classes the past year or so and I've written a couple text based games, but I think I'm ready to move onto the 2D world. Is there a library that's well renowned around here, written in either C++ or Java, that is easy for beginners and has a nice database of tutorials and such? I've googled quite a bit for these and there just seems to be an overwhelming amount. I don't want to waste time learning a library to turns out to be rather crummy.

Sorry if this has been asked, but there isn't really any information like this in the OP and I'm not seeing any threads for beginners.

Shavnir
Apr 5, 2005

A MAN'S DREAM CAN NEVER DIE

Bakkon posted:

I've been taking programming classes the past year or so and I've written a couple text based games, but I think I'm ready to move onto the 2D world. Is there a library that's well renowned around here, written in either C++ or Java, that is easy for beginners and has a nice database of tutorials and such? I've googled quite a bit for these and there just seems to be an overwhelming amount. I don't want to waste time learning a library to turns out to be rather crummy.

Sorry if this has been asked, but there isn't really any information like this in the OP and I'm not seeing any threads for beginners.

I've had a bit of experience with Slick (slick.cokeandcode.com) and while there's a few odd design decisions in there I like that it just handles the game loop / render loop for you and leaves you to game logic.

EDIT : To clarify Slick's more a framework and it handles a LOT of behind the scenes stuff.

Shavnir fucked around with this message at 17:47 on Apr 20, 2009

Vinterstum
Jul 30, 2003

Bakkon posted:

I've been taking programming classes the past year or so and I've written a couple text based games, but I think I'm ready to move onto the 2D world. Is there a library that's well renowned around here, written in either C++ or Java, that is easy for beginners and has a nice database of tutorials and such? I've googled quite a bit for these and there just seems to be an overwhelming amount. I don't want to waste time learning a library to turns out to be rather crummy.

Sorry if this has been asked, but there isn't really any information like this in the OP and I'm not seeing any threads for beginners.

SDL. It's -very- widely used, it's cross platform, and handles window management, graphics, sound, input, etc.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
SDL is not a game engine or framework, and it seems like Bakkon is looking for one of those, because of his "easy for beginners" requirement.

Bakkon
Jun 7, 2006

SQUIRTLE SQUAD
Looks like Slick will cover me for Java and SDL for C++. I'll tinker around with them a bit this summer. Thanks guys.

When a said "for a beginner," I just meant something that's simple to understand for someone who hasn't programmed outside of the standard provided libraries. SDL seems to have plenty of tutorials, so I think I'll be able to handle it. :)

Morpheus
Apr 18, 2008

My favourite little monsters
I've recently started looking into programming games with GUIs, and I haven't really thought about it before, but I realize that I have no idea how game GUIs are made. Are each of the components created anew to each engine? How does one make a text box (buttons and the like are easy)? How do you go about making an in-game dialog box that returns a value? (I'm really curious about that one)

I'm using XNA right now, and that has some libraries that I might be able to use, but I'm frankly more interested in how they actually work, code wise.

VVV Tons of help, thanks!

Morpheus fucked around with this message at 15:53 on Apr 21, 2009

Vinterstum
Jul 30, 2003

Morpheus posted:

I've recently started looking into programming games with GUIs, and I haven't really thought about it before, but I realize that I have no idea how game GUIs are made. Are each of the components created anew to each engine? How does one make a text box (buttons and the like are easy)? How do you go about making an in-game dialog box that returns a value? (I'm really curious about that one)

I'm using XNA right now, and that has some libraries that I might be able to use, but I'm frankly more interested in how they actually work, code wise.

A basic approach:

* Make a class that can render a bitmap to your screen, alpha-blended, at certain x,y coordinates and with a set width/height. This is your base class, call it GUIElement.
* Make a Text class which inherits from this, and can render a given text string into the bitmap (probably using a library like freetype2 in C++, presumably XNA has some inbuilt stuff for this).
* Make a Button class which also inherits from GUIElement, and changes its bitmap based on state (Normal, pressed, etc).
* Make a Container object which can contain several GUIElement objects, with a specific layout (at a basic level, each component could have offsets where they should be rendered, from its parent Containers position).
* From the above components and a few other basic types, you can build pretty much any type of GUI. A Dialog, for example, would probably have some kind of basic GUIElement object(s) for the background and frame, a Text object that you'll update when the user enters text, and one or more buttons.

Your widgets can then receive input events (mouse, keyboard) if they need it (with the GUI handler doing hit tests to see which exact GUI element the cursor is over when a mouse is pressed), and have some sort of callback system to the rest of your code for things like Yes/No dialog boxes and text input (i.e. whatever part of your code creates a specific GUI element can tell it to call local function X with the result).

Most basic GUI systems will be a variation of this, I believe :).

terminatusx
Jan 27, 2009

:megaman:Indie Game Dev and Bringer of the Apocalypse

Vinterstum posted:

stuff about programming GUIs :eng101:

Good stuff, goon sir :respek:

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH
Does anyone have any suggested resources for doing 2d collision detection and resolution with bounding circles and (non axis-aligned) rectangles?

Right now I plan on using a quadtree for static objects, but am not sure what structure to use for dynamic objects - however this may be few enough that it won't matter (less than 100).

I have a pretty good general understanding of how to do efficient simple collision detection (i.e., is a bounding circle/rectangle overlapping with another?), but there are two areas where I am a bit unsure:

1) Consider a player (dynamic circle) moving into a wall (static rectangle) and performing collision detection against it before the move occurs to prevent the move from happening if there would be a collision. What if the player is moving such a large amount (in one frame) that it would be completely jumping over the wall. How do I prevent this? In simple terms, I would need to perform ray casting between the player's current position and the move position to make sure there's nothing in between. How is this done?

2) When the above collision detection occurs and the player is going to be colliding with a wall, I don't want to simply deny the move, I would want to move the player as close to the wall as possible. How is this done? I.e., how do I get the distance between the player's circle and the wall's rectangle given the movement vector? This also seems like it would be solved with ray casting.


Keep in mind that this is being done in a relatively simple 2d non-tiled world with not so many objects.


edit: I guess what I am describing is more so collision detection between a line and a circle/rectangle than it is ray casting.

supster fucked around with this message at 12:07 on Apr 26, 2009

a slime
Apr 11, 2005

I am by no means an expert on collision detection, so keep that in mind.

supster posted:

1) Consider a player (dynamic circle) moving into a wall (static rectangle) and performing collision detection against it before the move occurs to prevent the move from happening if there would be a collision. What if the player is moving such a large amount (in one frame) that it would be completely jumping over the wall. How do I prevent this? In simple terms, I would need to perform ray casting between the player's current position and the move position to make sure there's nothing in between. How is this done?

2) When the above collision detection occurs and the player is going to be colliding with a wall, I don't want to simply deny the move, I would want to move the player as close to the wall as possible. How is this done? I.e., how do I get the distance between the player's circle and the wall's rectangle given the movement vector? This also seems like it would be solved with ray casting.

This is usually referred to as "tunneling", and most collision detection approaches simply assume that the time step and object velocities are small enough to prevent it. If you want a 100% guarantee that objects will never tunnel, you need to implement continuous collision detection.

I have implemented continuous collision detection with AABBs in a project I'm working on. Extending it to arbitrary polygons isn't that hard, either. Essentially you can reduce testing for the collision of any two moving polygons to testing for the collision of a static polygon and a ray, i.e. between the objects' Minkowski difference and their relative movement vector.

The general idea can be gleamed from some 2006 GDC slides on the subject which you can find here. I'm not sure how difficult it would be to support rotation as well, but I can't imagine it would be that bad.

newsomnuke
Feb 25, 2007

The simplest thing to do would be to treat the wall/OBB as individual lines. Then you can take the circle's current and projected positions and create a line from them to test against the wall lines.

ahobday
Apr 19, 2007

I'm looking to play around with an idea similar to that of The Unfinished Swan, in terms of the presentation. I'm not replicating the paint throwing mechanic at all.

I suspect all I need is a mapping tool and an FPS engine to use. I could always use the Source engine, but I was wondering if anyone had any alternate suggestions? The game would feature an all-black world, with nothing but black textures and some lighting at some points. It would also have no guns or any other player models on screen.

A different engine would also (Potentially) mean if I ever got around to making anything out of it I could distribute it stand-alone rather than as a mod for Source. I guess, however, that the only real reason I'm asking is that there might be something simpler out there than the Source engine/Hammer editor, given that my needs aren't great.

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH

not a dinosaur posted:

I am by no means an expert on collision detection, so keep that in mind.


This is usually referred to as "tunneling", and most collision detection approaches simply assume that the time step and object velocities are small enough to prevent it. If you want a 100% guarantee that objects will never tunnel, you need to implement continuous collision detection.

I have implemented continuous collision detection with AABBs in a project I'm working on. Extending it to arbitrary polygons isn't that hard, either. Essentially you can reduce testing for the collision of any two moving polygons to testing for the collision of a static polygon and a ray, i.e. between the objects' Minkowski difference and their relative movement vector.

The general idea can be gleamed from some 2006 GDC slides on the subject which you can find here. I'm not sure how difficult it would be to support rotation as well, but I can't imagine it would be that bad.
Thanks for the info.

I am now more interested in what data structures to store my static and dynamic data in. For static structures I'm pretty sure I'll be using a quadtree. For dynamic objects (i.e., constantly moving) I am not sure what data structure to use.

supster fucked around with this message at 10:07 on Apr 29, 2009

a slime
Apr 11, 2005

Until you have a pressing reason to do otherwise (with < 100 objects you do not), just throw them in a linked list.

The1ManMoshPit
Apr 17, 2005

supster posted:

Thanks for the info.

I am now more interested in what data structures to store my static and dynamic data in. For static structures I'm pretty sure I'll be using a quadtree. For dynamic objects (i.e., constantly moving) I am not sure what data structure to use.

You could use a quad tree for dynamic objects as well or use a kd-tree. The benefits of a kd-tree are fast range-checks and nearest neighbour search on a per-object basis but you need to decide whether you need that or not. Building a kd-tree is more expensive than a quad tree but not so much that it's impractical.

Also like not a dinosaur said if you have only a few objects it might be easier to just store them in an array or whatever until the cost of working with unsorted data outweighs the cost of building a more efficient data structure, but that sucks for scalability (obviously) and can lead to refactoring troubles down the road if you code too much around a basic array or linked list.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

The1ManMoshPit posted:

You could use a quad tree for dynamic objects as well or use a kd-tree.

A quad tree for dynamic data is not so good unless you modify it a fair amount. Any object near the origin will be in the root node, so if you have a lot of action happening near the origin, you won't be seeing much benefit from using a quadtree.

You can modify the quadtree implementation to overcome this issue by allowing objects to overlap the boundaries, but that requires you to traverse more nodes when detecting collisions and results in most of the shallow (near root) nodes to be empty, which needlessly increases traversal cost. At that point, you might as well nix the quadtree entirely and use a hierarchical grid instead.

The1ManMoshPit
Apr 17, 2005

That's true, but in general it's not horribly inefficient either. Plus if he's already got a quadtree for his static data he can reuse some work for his dynamic stuff with really little effort. Its worst-case performance is going to be close to a flat array anyway so if he's considering quadtree or flat array quadtree isn't a bad choice.

A kd-tree or sparse grid of some sort is probably best, I just tend to avoid grids because I find the code for them harder to write, but that's personal preference really. Other people probably feel the same way about trees.

nolen
Apr 4, 2004

butts.
I was curious if anyone knew of the most efficient way to spawn an arbitrary number of bullets from a specified point in a "fan" type pattern.

This image should help illustrate what I mean:




So if I spawn one bullet, it more or less goes straight down, two bullets is split left and right, three has a left, a center, and a right, and so on.

It sort of makes me think of drawing a circle out of multiple points, but even that is a bit beyond me.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Think of it this way: you want to have n bullets' angles spaced evenly over the x-axis. So, assuming it's firing from the origin, one bullet is being fired at -90 degrees, two are at -60 and -120, three are at -45, -90, and -135 degrees...think about how these values are related to one another.

or just give it away AD sure that's ok too I guess :mad:

Dijkstracula fucked around with this message at 23:10 on Apr 29, 2009

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Just pick a minimum and maximum angle for the bullet spread and then step through that range and use sin/cos to get the x and y deltas. e.g.

θmin = 240°
θmax = 300°
n = 5
s = 10 m/s
Δθ = (θmax - θmin)/n = (300°-240°)/5 = 12°

for &theta = θmin to θmax step Δθ
    v = s ⋅ (cos θ, sin θ)
    new Bullet(v)

Avenging Dentist fucked around with this message at 23:12 on Apr 29, 2009

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Dijkstracula posted:

or just give it away AD sure that's ok too I guess :mad:

Hey gently caress you buddy I wanted to use math symbols in HTML today. :colbert:

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Avenging Dentist posted:

Hey gently caress you buddy I wanted to use math symbols in HTML today. :colbert:
The Something Awful Forums > Discussion > Serious Hardware / Software Crap > The Cavern of COBOL > APL Questions Not Worth Their Own Thread

...all right, sorry, I'll get back on track

POKEMAN SAM
Jul 8, 2004

Avenging Dentist posted:

Just pick a minimum and maximum angle for the bullet spread and then step through that range and use sin/cos to get the x and y deltas. e.g.

θmin = 240°
θmax = 300°
n = 5
s = 10 m/s
Δθ = (θmax - θmin)/n = (300°-240°)/5 = 12°

for &theta = θmin to θmax step Δθ
    v = s ⋅ (cos θ, sin θ)
    new Bullet(v)

How does this work for one bullet? The bullet wouldn't be pointing at 270° like you'd expect it to from his drawing.

Edit: Don't you want to split the semi-circle (or whatever the arc is between min and max degrees) into n regions, and then in each of those regions fire a bullet toward the center of that region's arc? Then it would work for 1 bullet, it just means that the min and max will never actually have a bullet fired at that angle, though it will tend toward them as n increases...

POKEMAN SAM fucked around with this message at 23:32 on Apr 29, 2009

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Ugg boots posted:

How does this work for one bullet? The bullet wouldn't be pointing at 270° like you'd expect it to from his drawing.

It doesn't, that's why I specified n=5. :)

(I assumed he could figure out how to make the n=1 case work on his own because it's not exactly complicated).

nolen
Apr 4, 2004

butts.
Thanks Dijkstracula and Avenging Dentist. The theory behind it was my stumbling block.

I think I have a better idea how I want to handle this now.

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

Avenging Dentist posted:

A quad tree for dynamic data is not so good unless you modify it a fair amount. Any object near the origin will be in the root node, so if you have a lot of action happening near the origin, you won't be seeing much benefit from using a quadtree.

You can modify the quadtree implementation to overcome this issue by allowing objects to overlap the boundaries, but that requires you to traverse more nodes when detecting collisions and results in most of the shallow (near root) nodes to be empty, which needlessly increases traversal cost. At that point, you might as well nix the quadtree entirely and use a hierarchical grid instead.

Traversal costs should be pretty drat negligible unless you're doing a freaking lot of traversals every frame. But yes, the "oversized" quad-tree or Sphere-tree is definitely the way to go, even for static objects (you can imagine the same problem occuring with a static object near the origin whose bounds overlap multiple regions).

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Hubis posted:

But yes, the "oversized" quad-tree or Sphere-tree is definitely the way to go, even for static objects (you can imagine the same problem occuring with a static object near the origin whose bounds overlap multiple regions).

Static objects would probably benefit from a fixed-size grid, where each object is a member of all the grid cells it overlaps. Fixed-size grids are really easy to write, too.

Adbot
ADBOT LOVES YOU

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

Avenging Dentist posted:

Static objects would probably benefit from a fixed-size grid, where each object is a member of all the grid cells it overlaps. Fixed-size grids are really easy to write, too.

That part is true. Unless you're working on a project where you have the "Teapot in a Stadium" problem, don't worry about it.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply