/* take a snapshot of the current mouse state */ void mouse_idle( short type) { Point where; Point center; static bool first_run = true; static int32 last_tick_count; int32 tick_count= TickCount(); int32 ticks_elapsed= tick_count-last_tick_count; if(first_run) { ticks_elapsed = 0; first_run = false; } get_mouse_location(&where); center.h= CENTER_MOUSE_X, center.v= CENTER_MOUSE_Y; set_mouse_location(center); if (ticks_elapsed) { /* calculate axis deltas */ _fixed vx= INTEGER_TO_FIXED(where.h-center.h)/(ticks_elapsed*MAXIMUM_MOUSE_VELOCITY); _fixed vy= - INTEGER_TO_FIXED(where.v-center.v)/(ticks_elapsed*MAXIMUM_MOUSE_VELOCITY); // ZZZ: mouse inversion if (TEST_FLAG(input_preferences->modifiers, _inputmod_invert_mouse)) vy *= -1; // LP: modified for doing each axis separately; // ZZZ: scale input by sensitivity if (input_preferences->sens_horizontal != FIXED_ONE) vx = _fixed((float(input_preferences->sens_horizontal)*vx)/float(FIXED_ONE)); if (input_preferences->sens_vertical != FIXED_ONE) vy = _fixed((float(input_preferences->sens_vertical)*vy)/float(FIXED_ONE)); if(input_preferences->mouse_acceleration) { /* pin and do nonlinearity */ vx= PIN(vx, -FIXED_ONE/2, FIXED_ONE/2), vx>>= 1, vx*= (vx<0) ? -vx : vx, vx>>= 14; vy= PIN(vy, -FIXED_ONE/2, FIXED_ONE/2), vy>>= 1, vy*= (vy<0) ? -vy : vy, vy>>= 14; } else {
/* every other field in the player structure should be valid when this call is made */ void initialize_player_physics_variables( short player_index) { struct player_data *player= get_player_data(player_index); struct monster_data *monster= get_monster_data(player->monster_index); struct object_data *object= get_object_data(monster->object_index); struct physics_variables *variables= &player->variables; struct physics_constants *constants= get_physics_constants_for_model(static_world->physics_model, 0); //#ifdef DEBUG obj_set(*variables, 0x80); //#endif variables->head_direction= 0; variables->adjusted_yaw= variables->direction= INTEGER_TO_FIXED(object->facing); variables->adjusted_pitch= variables->elevation= 0; variables->angular_velocity= variables->vertical_angular_velocity= 0; variables->velocity= 0, variables->perpendicular_velocity= 0; variables->position.x= WORLD_TO_FIXED(object->location.x); variables->position.y= WORLD_TO_FIXED(object->location.y); variables->position.z= WORLD_TO_FIXED(object->location.z); variables->last_position= variables->position; variables->last_direction= variables->direction; /* .floor_height, .ceiling_height and .media_height will be calculated by instantiate, below */ variables->external_angular_velocity= 0; variables->external_velocity.i= variables->external_velocity.j= variables->external_velocity.k= 0; variables->actual_height= constants->height; variables->step_phase= 0; variables->step_amplitude= 0; variables->action= _player_stationary; variables->old_flags= variables->flags= 0; /* not recentering, not above ground, not below ground (i.e., on floor) */ /* setup shadow variables in player_data structure */ instantiate_physics_variables(get_physics_constants_for_model(static_world->physics_model, 0), &player->variables, player_index, true, true); #ifdef DIVERGENCE_CHECK if (!saved_point_iterations) { saved_points= new world_point3d[SAVED_POINT_COUNT]; saved_thetas= new angle[SAVED_POINT_COUNT]; } saved_point_count= 0; saved_point_iterations+= 1; saved_divergence_warning= false; #endif }