Great!
To recap:
I'll be referring to that as I write my code; I figured it'd probably be useful for anyone looking to make more realistic explosions.
Also, something we haven't explored is that this also allows us to do a bit more while rendering our explosions. We've got data that shows exactly where the explosion can reach since rays are blocked from continuing after intersecting an object. We've even got normal vectors and collision points for each ray, which can be helpful for drawing sparks and effects that look like they bounce off of shapes, and should be much more efficient than instantiating physics particles to do that for us (though CCD does make it a whole lot more robust than it would have been otherwise). You could definitely use this to make some beautiful dynamics but I'm afraid I wont be able to come up with something that looks all that good. In my program I've only had success making pretty things using various shader effects (bloom + per pixel displacement) and my textures have come out terrible looking so far. Though a nice distorting, expanding shockwave effect which gets reflected by objects, would certainly look very nice, and I think I can do that. Someone needs to show me how to make nice looking fireballs, sparks, and smoke though.
To recap:
Code: Select all
/* Methodology:
* Force applied at a ray is inversely proportional to the square of distance from source
* AABB is used to query for shapes that may be affected
* use AABB that is sufficiently large so that the non circular shape doesn't cause discernible difference
* For each RIGID BODY (not shape -- this is an optimization) that is matched, loop through its vertices to determine
* the extreme points -- if there is structure that contains outlining polygon, use that as an additional optimization
* Evenly cast a number of rays against the shape - number roughly proportional to the arc coverage
* -Something like every 3 degrees should do the trick although this can be altered depending on the distance (if really close don't need such a high density of rays)
* -There should be a minimum number of rays (3-5?) applied to each body so that small bodies far away are still accurately modeled
* -Be sure to have the forces of each ray be proportional to the average arc length covered by each.
* For each ray that actually intersects with the shape (non intersections indicate something blocking the path of explosion):
* > apply the appropriate force dotted with the negative of the collision normal at the collision point
* > optionally apply linear interpolation between aforementioned Normal force and the original explosion force in the direction of ray to simulate "surface friction" of sorts
*/
I'll be referring to that as I write my code; I figured it'd probably be useful for anyone looking to make more realistic explosions.
Also, something we haven't explored is that this also allows us to do a bit more while rendering our explosions. We've got data that shows exactly where the explosion can reach since rays are blocked from continuing after intersecting an object. We've even got normal vectors and collision points for each ray, which can be helpful for drawing sparks and effects that look like they bounce off of shapes, and should be much more efficient than instantiating physics particles to do that for us (though CCD does make it a whole lot more robust than it would have been otherwise). You could definitely use this to make some beautiful dynamics but I'm afraid I wont be able to come up with something that looks all that good. In my program I've only had success making pretty things using various shader effects (bloom + per pixel displacement) and my textures have come out terrible looking so far. Though a nice distorting, expanding shockwave effect which gets reflected by objects, would certainly look very nice, and I think I can do that. Someone needs to show me how to make nice looking fireballs, sparks, and smoke though.
