#include <msp/datafile/packsource.h>
#include <msp/fs/stat.h>
#include <msp/fs/utils.h>
+#include <msp/geometry/angle.h>
#include <msp/graphics/display.h>
#include <msp/graphics/window.h>
#include <msp/gl/animatedobject.h>
GL::DirectionalLight light;
GL::Lighting lighting;
GL::Camera camera;
- float yaw;
- float pitch;
+ Geometry::Angle<float> yaw;
+ Geometry::Angle<float> pitch;
float distance;
- float light_yaw;
- float light_pitch;
+ Geometry::Angle<float> light_yaw;
+ Geometry::Angle<float> light_pitch;
unsigned dragging;
Time::TimeStamp last_tick;
renderable(0),
anim_object(0),
anim_player(0),
- yaw(0),
- pitch(0),
distance(10),
- light_yaw(0),
- light_pitch(0),
dragging(0)
{
for(list<string>::const_iterator i=opts.resource_locations.begin(); i!=opts.resource_locations.end(); ++i)
float dx = (axis==0 ? delta : 0);
float dy = (axis==1 ? delta : 0);
- yaw -= dx*M_PI*2;
- while(yaw>M_PI)
- yaw -= M_PI*2;
- while(yaw<-M_PI)
- yaw += M_PI*2;
+ yaw -= Geometry::Angle<float>::from_turns(dx);
+ yaw.wrap_balanced();
- pitch += dy*M_PI;
- if(pitch>M_PI*0.49)
- pitch = M_PI*0.49;
- if(pitch<-M_PI*0.49)
- pitch = -M_PI*0.49;
+ pitch += Geometry::Angle<float>::from_turns(dy*0.5f);
+ pitch = min(max(pitch, Geometry::Angle<float>::from_turns(-0.24f)), Geometry::Angle<float>::from_turns(0.24f));
update_camera();
}
float x = mouse.get_axis_value(0);
float y = mouse.get_axis_value(1);
- light_yaw = yaw+x*M_PI;
- light_pitch = pitch-y*M_PI;
+ light_yaw = yaw+Geometry::Angle<float>::from_turns(x*0.5f);
+ light_pitch = pitch-Geometry::Angle<float>::from_turns(y*0.5f);
update_light();
}