11 if ( target >= this->
begin() && target < this->
end() ) {
14 size_t diff = ( target-this->
begin() );
22 }
else if (target == NULL) {
27 std::list< CollidableBackref >::iterator endlist = targlist->end();
28 for (std::list< CollidableBackref >::iterator
i = targlist->begin();
i != endlist; ++
i)
37 if ( iter >= this->
begin() && iter < this->
end() ) {
40 }
else if ( !
is_null( iter ) ) {
46 if ( iter >= this->
begin() && iter < this->
end() ) {
62 template <
int direction,
bool always_replace >
66 double last_radius_key;
68 float last_big_radius;
69 double last_big_radius_key;
76 last_big_radius_key = 0;
81 double key = collidable.
getKey();
82 float rad = collidable.
radius;
84 if (rad > last_big_radius) {
85 last_radius = last_big_radius = rad;
86 last_radius_key = last_big_radius_key = key;
87 }
else if (rad > last_radius) {
89 last_radius_key = key;
90 }
else {last_radius_key = key; }}
92 last_big_radius = last_radius;
93 last_big_radius_key = last_radius_key;
95 last_radius_key = key;
97 if (always_replace || cm->
max_radius[index] < last_big_radius)
102 template <
int location_index >
109 assert( collidable.
radius != 0.0f );
128 for (ptrdiff_t
i = len;
i >= 0;
i--) {
130 if (
i < static_cast<ptrdiff_t>(len) && (tmp = &
unsorted[
i])->radius != 0.0
f) {
132 collideUpdate( *tmp, index );
135 std::list< CollidableBackref >::iterator listend =
toflattenhints[i].end();
139 if (
j->radius != 0) {
141 collideUpdate( *
j, index );
153 ResizableArray::iterator iter =
sorted.begin();
156 for (i = 0; i !=
size; ++i, ++iter) {
158 radUpdate( *iter, i );
163 assert( 0 &&
"Only Support arrays of units_only and mixed units bolts" );
171 public:
CopyExample( CollideArray::ResizableArray::iterator beg, CollideArray::ResizableArray::iterator end )
206 printf(
"Trying to use flatten hint on a array with both bolts and units\n" );
215 if ( this->
begin() == this->
end() ) {
219 this->
sorted.push_back( newKey );
221 }
else if ( hint >= this->
begin() && hint <= this->
end() ) {
223 size_t len = hint-this->
begin();
227 return this->
insert( newKey );
233 return ::std::lower_bound( this->
begin(), this->
end(), newKey );
243 for (
iterator newiter = this->
begin(), iter = newiter++; newiter != this->
end(); iter = newiter++)
244 assert( *iter < *newiter );
265 return input->location[location_index];
278 template <
class T,
bool canbebolt >
284 double mid = (minlook+maxlook)*.5;
285 minlook = (minlook+mid)*.5-tmptmore->
radius;
286 maxlook = (maxlook+mid)*.5+tmptmore->
radius;
292 unsigned int location_index,
299 if (backref_obtain( un, location_index ) != cmbegin) {
301 while ( (*tless)->getKey() >= minlook ) {
302 float rad = (*tless)->radius;
303 bool boltSpecimen = canbebolt && (rad < 0);
306 if (tless == cmbegin) {
307 if (canbebolt && boltSpecimen) {
312 }
else {
break; }}
else if (rad != 0) {
313 if ( canbebolt ==
true &&
BoltType( un ) ) {
327 }
else {
break; }}
else {
break; }}
else {
328 if (canbebolt && boltSpecimen) {
332 }
else if (rad != 0) {
333 if ( canbebolt ==
true &&
BoltType( un ) ) {
352 while (tmore != cmend && (*tmore)->
getKey() <= maxlook) {
353 float rad = (*tmore)->
radius;
354 bool boltSpecimen = canbebolt && (rad < 0);
356 if (canbebolt && boltSpecimen) {
360 }
else if (rad != 0) {
362 if ( canbebolt ==
true &&
BoltType( un ) ) {
388 maxlook = sortedloc+2.0625*radius;
389 minlook = sortedloc-2.0625*radius;
402 float dboltdist = -2.0625*rad;
403 float boltdist = -1.0625*rad;
404 if (collider >= cmbegin && collider < cmend) {
405 float maxrad = cm->
max_radius[collider-cmbegin];
409 if (dboltdist < boltdist)
410 boltdist = dboltdist;
411 }
else {boltdist += fabs( rad ); } maxlook = sortedloc+boltdist;
412 minlook = sortedloc-boltdist;
418 double sortedloc = collider.
getKey();
419 float rad = collider.
radius;
422 if (cmbegin == cmend)
return false;
423 double minlook, maxlook;
425 if (
ComputeMaxLookMinLook( un, cm, startIter, cmbegin, cmend, sortedloc, rad, minlook, maxlook ) )
return false;
431 tless = tmore = tmploc;
433 tless = tmore = startIter;
434 if (tless != cmbegin)
439 un, collider, location_index,
463 return ( a.
GetPosition()-b.
GetPosition() ).MagnitudeSquared() > aradius*aradius+aradius*bradius*2+bradius*bradius;
471 if (fabs( tempy ) > radiussum || fabs( tempz ) > radiussum)
477 return (tempx+tempy+tempz) > radiussum*radiussum;