View Full Version : CocoaBlitz now has documentation!
kelvin
2003.08.04, 09:27 AM
I've written a primer for CocoaBlitz (http://www.variableaspect.com/experiments/CocoaBlitz). It's pretty basic for now, but I think its enough to get a good understanding of how CocoaBlitz works. I've yet to document all the methods available, but the CBCell.h header has extensive commenting; You'll still have to dig into the headers for now.
primer is here:
http://www.variableaspect.com/experiments/CocoaBlitz/primer.html
flipflop
2003.08.04, 01:10 PM
Thanks Kelvin! This is a very helpful overview. One comment I do have is in regards to the
[CBCell collidesWith:withinRadius: polygonAccurate:]
method. Looking at the CBCell.h file for more details I feel this method is doing too much to the point it is a bit confusing to use.
// Collision Detection
// Cells check distance between locs, so setting your regPoint to the center of mass of your texture
// will make this method more accurate. By setting a radius of NULL this method will skip distance
// check and go straight to polygon collision. polyac must be set to YES to handle polygon-accurate
// collisions. PolyAC collisions are costly interms of speed so it's good to keep a reasonably small
// radius parameter so the polygon code is run less.
// Setting radius negative will make CB use polygon centroid calculations determine a radius.
// Setting polyac to NO will do only distance checking; if speed is a big concern.
// NULL radius and NO polyac will return YES in all cases. Silly if you ask me.
... perhaps it might be better to split out the polygonal and radial collision detection into two separate methods. You can leave this method available for power programmers but hide the details from the not-so-powerful users (like me) :p
Thanks again for the documentation. I hope a lot of people use your framework and give you solid feedback!
skyhawk
2003.08.04, 01:17 PM
I think it is better left as one method, and have an easy preference or #define for whether you want high quality or low quality collision
kelvin
2003.08.04, 01:17 PM
The reason behind putting radius and polyac collision detection in the same method was for optimization reasons. Radius checking is A LOT faster than polygon checking. So given an intelligent radius to check, the polygon check can be skipped if the radius check fails. If you don't feel like figuring out the radius to check, then simply pass a negative number as a the radius, CB will calculate a good radius based on the cells' centroid geometry. Conversely if you're doing circular collisions, simply pass NO to polygonAccurate:.
your best bet, if you're doing something like a shooter is to pass a radius of -1 and polyac of YES. This is the setup you want.
flipflop
2003.08.04, 01:21 PM
Originally posted by skyhawk
I think it is better left as one method, and have an easy preference or #define for whether you want high quality or low quality collision
Sounds useful, do you have a small C example of what the #define might look like? I'm a bit (OK, a LOT) rusty with my C...
kelvin
2003.08.04, 01:29 PM
#define Collide(aCell, bCell) [aCell collidesWith:bCell withinRadius:-1.0f polygonAccurate:YES]
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.