本文整理汇总了C++中Pair::check_distance方法的典型用法代码示例。如果您正苦于以下问题:C++ Pair::check_distance方法的具体用法?C++ Pair::check_distance怎么用?C++ Pair::check_distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pair
的用法示例。
在下文中一共展示了Pair::check_distance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update_world
//.........这里部分代码省略.........
pr = new StaticDynPair(st,*dyn_it);
else if( dyn.valid() )
pr = new DynDynPair(dyn,*dyn_it);
else if( sh.valid() )
pr = new ShotDynPair(sh,*dyn_it);
pr->calc_lower_bound();
prio_queue.insert(pr);
}
}
}
for(int i = 0;i < obsolete_keys.size();++i){
collision_table.remove(dyn_it->get_id(),obsolete_keys[i]);
const set<int> ids = collision_table.get_ids(new_keys[i]);
for(std::set<int>::const_iterator j = ids.begin();j != ids.end(); ++j){
close_pairs.decrease(dyn_it->get_id(),*j);
}
}
new_keys.clear();
obsolete_keys.clear();
}
double mid = stopwatch();
if(!prio_queue.empty()) {
while( !prio_queue.empty() && prio_queue.top()->get_lower_bound() < frame_stop ) {
//Now check if we want to simulate a collision between objects
Pair* pair = prio_queue.top();
double dt = pair->get_lower_bound() - pair->get_sim_time();
if(dt < 0)
cout << "Neg dt!" << endl;
//the object will be simulated this far when the loop has ended
//prio_queue.pop();
//Pair simulate simulates until lower_bound
pair->simulate( pair->get_lower_bound() );
if(pair->check_distance() < Collision_Distance ) {
if (pair->collide( *(pair->get_collision()) ) )
prio_queue.update_if(tstId(pair->get_id1(), pair->get_id2() ));
}
if( to_insert(frame_stop,*pair) ) {
pair->calc_lower_bound();
prio_queue.update(pair);
}
else{
prio_queue.pop();
delete pair;
}
}
}
double mid2 = stopwatch();
//Now simulate all objects until framestop
//Simulate all aobjekt so that they have a simtime of end of fram
for(dyn_iterator i(wr->begin_dyn()); i != wr->end_dyn(); ++i){
double dt = frame_stop - i->get_sim_time();
if(dt < 0 )
cout << "Negative dt!" << dt <<endl;
i->simulate(dt);
}
double end = stopwatch();
cout << "Timing info Hash: " << mid - start << " treap: " << mid2 - mid << endl;
/*
for(st_iterator i(wr->begin_st()); i != wr->end_st(); ++i){
double dt = frame_stop - i->get_sim_time();
i->simulate(dt);
}
for(shot_iterator i(wr->begin_shot()); i != wr->end_shot(); ++i){
double dt = frame_stop - i->get_sim_time();
i->simulate(dt);
}
*/
}