All pastes #1045338 Raw Edit

Someone

public python v1 · immutable
#1045338 ·published 2008-06-11 19:54 UTC
rendered paste body
# THIS IS GPLed BITCHES# DON'T RIP IT OFF# Copyright(C) 2008 Litesim Ltddef 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.remove(update)       for update in pending_phys_updates:          if update['type'] == 'stop':             local_id = update['local_id']             scene_objects[local_id]['vel_x'] = 0.0             scene_objects[local_id]['vel_y'] = 0.0             scene_objects[local_id]['vel_z'] = 0.0       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_objects[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[obj_id]['pos_z'])) or (not (old_moving==obj_moving(obj_id))):              mark_obj_pos_dirty(obj_id)	   if (scene_objects[obj_id]['vel_x']==0.0) or (scene_objects[obj_id]['vel_y']==0.0):              mark_obj_pos_dirty(obj_id)       scene_lock.release()def idle_loop():    global scene_lock    while running:       for obj_id in scene_objects.keys():           if not obj_moving(obj_id):              try:                scene_lock.acquire(True)                if scene_objects[obj_id]['vel_x']>0.0:                   scene_objects[obj_id]['vel_x'] = scene_objects[obj_id]['vel_x']-0.0025                elif scene_objects[obj_id]['vel_x']<0.0:                   scene_objects[obj_id]['vel_x'] = scene_objects[obj_id]['vel_x']+0.0025                if scene_objects[obj_id]['vel_y']>0.0:                   scene_objects[obj_id]['vel_y'] = scene_objects[obj_id]['vel_y']-0.0025                elif scene_objects[obj_id]['vel_y']<0.0:                   scene_objects[obj_id]['vel_y'] = scene_objects[obj_id]['vel_y']+0.0025                if scene_objects[obj_id]['vel_z']>0.0:                   scene_objects[obj_id]['vel_z'] = scene_objects[obj_id]['vel_z']-0.0025                elif scene_objects[obj_id]['vel_z']<0.0:                   scene_objects[obj_id]['vel_z'] = scene_objects[obj_id]['vel_z']+0.0025                scene_lock.release()              except Exception, e:                print str(e)    time.sleep(2.5)