void RAS_BucketManager::OrderBuckets(const MT_Transform& cameratrans, BucketList& buckets, vector<sortedmeshslot>& slots, bool alpha) { BucketList::iterator bit; list<RAS_MeshSlot>::iterator mit; size_t size = 0, i = 0; /* Camera's near plane equation: pnorm.dot(point) + pval, * but we leave out pval since it's constant anyway */ const MT_Vector3 pnorm(cameratrans.getBasis()[2]); for (bit = buckets.begin(); bit != buckets.end(); ++bit) { SG_DList::iterator<RAS_MeshSlot> mit((*bit)->GetActiveMeshSlots()); for(mit.begin(); !mit.end(); ++mit) size++; } slots.resize(size); for (bit = buckets.begin(); bit != buckets.end(); ++bit) { RAS_MaterialBucket* bucket = *bit; RAS_MeshSlot* ms; // remove the mesh slot form the list, it culls them automatically for next frame while((ms = bucket->GetNextActiveMeshSlot())) { slots[i++].set(ms, bucket, pnorm); } } if(alpha) sort(slots.begin(), slots.end(), backtofront()); else sort(slots.begin(), slots.end(), fronttoback()); }
void print_bucket_list ( const BucketList &bl , std::ostream &os ) { BucketList::const_iterator cur_bucket = bl.begin(); while ( cur_bucket != bl.end() ) { os << "Bucket key: "; //This is bad code, no longer works. Re-visit this if/when the //Transaction class is ever resurrected. // for ( unsigned i = 0 ; i <= (*cur_bucket)->m_key[0] ; i++ ) // os << (*cur_bucket)->m_key[i] << " "; // os << "\n"; // os << "Entities: "; // for ( unsigned i = 0 ; i != (*cur_bucket)->m_size ; i++ ) // os << (*cur_bucket)->m_entities[i]->identifier() << " "; // os << "\n-------------------\n"; cur_bucket++; } }