All pastes #904594 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-02-15 01:56 UTC
rendered paste body
def do_phys_updates(cur,last):
    global processing
    global pending_phys_updates
    global the_time
    global last_time
    the_time = cur
    last_time = last
    while running:
       time.sleep(0.005)
       last_time = the_time
       the_time = time.time()
       timestep = the_time = last_time
       scene_lock.acquire(True)
       for update in pending_phys_updates:
          if update['type'] == 'force':
             local_id = update['local_id']
             scene_objects[local_id]['vel_x'] = update['new_velx']
             scene_objects[local_id]['vel_y'] = update['new_vely']
             scene_objects[local_id]['vel_z'] = update['new_velz']
       pending_phys_updates = []
       scene_lock.release()
       scene_lock.acquire(True)
       for obj_id in scene_objects.keys():
           old_posx = scene_objects[obj_id]['pos_x']
           old_posy = scene_objects[obj_id]['pos_y']
           old_posz = scene_objects[obj_id]['pos_z']
           old_moving = obj_moving(obj_id)
           scene_objects[obj_id]['pos_x'] = scene_objects[obj_id]['pos_x'] + scene_objects[obj_id]['vel_x']
           scene_objects[obj_id]['pos_y'] = scene_objects[obj_id]['pos_y'] + scene_objects[obj_id]['vel_y']
           if (scene_objects[obj_id]['pos_x'] > 254.9) or (scene_objects[obj_id]['pos_x'] < 0.1) or (scene_objects[obj_id]['pos_y'] > 254.9) or (scene_objec
ts[obj_id]['pos_y'] < 0.1):
              scene_objects[obj_id]['pos_x'] = old_posx - scene_objects[obj_id]['vel_x']
              scene_objects[obj_id]['pos_y'] = old_posy - scene_objects[obj_id]['vel_y']
              scene_objects[obj_id]['vel_x'] = 0
              scene_objects[obj_id]['vel_y'] = 0
           scene_objects[obj_id]['pos_z'] = get_ter_height(scene_objects[obj_id]['pos_x'],scene_objects[obj_id]['pos_y'])+1

           if (not (old_posx == scene_objects[obj_id]['pos_x'])) or (not (old_posy == scene_objects[obj_id]['pos_y'])) or (not (old_posz == scene_objects[ob
j_id]['pos_z'])) or (not (old_moving==obj_moving(obj_id))):
              mark_obj_pos_dirty(obj_id)
       scene_lock.release()