1
0
Fork 0

Merge branch 'next' of gitorious.org:fg/flightgear into next

This commit is contained in:
Torsten Dreyer 2011-09-21 19:19:10 +02:00
commit d860c949e3
14 changed files with 76 additions and 124 deletions

View file

@ -49,6 +49,12 @@ else()
set(HUDSON_BUILD_ID "none")
endif()
IF(APPLE)
set(EVENT_INPUT_DEFAULT 1)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(EVENT_INPUT_DEFAULT 1)
endif()
find_package(Git)
if (GIT_FOUND)
execute_process(COMMAND git --git-dir ${PROJECT_SOURCE_DIR}/.git rev-parse HEAD
@ -67,7 +73,7 @@ option(ENABLE_LARCSIM "Set to ON to build FlightGear with LaRCsim FDM" ON)
option(ENABLE_YASIM "Set to ON to build FlightGear with YASIM FDM" ON)
option(ENABLE_JSBSIM "Set to ON to build FlightGear with JSBSim FDM" ON)
option(ENABLE_FGADMIN "Set to ON to build FlightGear with FGADMIN" ON)
option(EVENT_INPUT "Set to ON to build FlightGear with event-based Input support" OFF)
option(EVENT_INPUT "Set to ON to build FlightGear with event-based Input support" ${EVENT_INPUT_DEFAULT})
option(ENABLE_LIBSVN "Set to ON to build FlightGear/terrasync with libsvnclient support" ON)
option(ENABLE_RTI "Set to ON to build SimGear with RTI support" OFF)
option(WITH_FGPANEL "Set to ON to build the fgpanel application" ON)
@ -98,20 +104,6 @@ if(SP_FDMS)
set(ENABLE_SP_FDM 1)
endif()
if(EVENT_INPUT)
message(STATUS "checking event-based Input")
find_package(DBus)
IF(APPLE)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
else()
message(WARNING "event input is not supported on this platform yet")
endif()
else(EVENT_INPUT)
set(ENABLE_PLIB_JOYSTICK 1)
endif(EVENT_INPUT)
if (MSVC AND MSVC_3RDPARTY_ROOT)
message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_ROOT}")
set( OSG_MSVC "msvc" )
@ -135,6 +127,24 @@ if (MSVC AND MSVC_3RDPARTY_ROOT)
set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib)
endif (MSVC AND MSVC_3RDPARTY_ROOT)
if(EVENT_INPUT)
message(STATUS "checking event-based Input")
IF(APPLE)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(DBus)
if(NOT DBUS_FOUND)
message(WARNING "DBus not found, event input will be disabled")
set(EVENT_INPUT 0)
endif()
else()
message(WARNING "event input is not supported on this platform yet")
endif()
else(EVENT_INPUT)
set(ENABLE_PLIB_JOYSTICK 1)
endif(EVENT_INPUT)
# check required dependencies
find_package(Boost REQUIRED)

View file

@ -322,7 +322,7 @@ void fgHiResDump()
int curColumn = trGet(tr, TR_CURRENT_COLUMN);
// int curRow = trGet(tr, TR_CURRENT_ROW);
renderer->update( false );
renderer->update();
// OSGFIXME
// if ( do_hud )
// fgUpdateHUD( curColumn*hud_col_step, curRow*hud_row_step,

View file

@ -2,8 +2,12 @@ include(FlightGearComponent)
IF(APPLE)
set(EVENT_INPUT_SOURCES FGMacOSXEventInput.cxx)
set(EVENT_INPUT_HEADERS FGMacOSXEventInput.hxx)
else(MSVC)
message(STATUS "EventInput not implemented for Windows yet")
else()
set(EVENT_INPUT_SOURCES FGLinuxEventInput.cxx)
set(EVENT_INPUT_HEADERS FGLinuxEventInput.hxx)
endif()
@ -31,6 +35,7 @@ set(HEADERS
if(EVENT_INPUT)
list(APPEND SOURCES ${EVENT_INPUT_SOURCES})
list(APPEND SOURCES ${EVENT_INPUT_HEADERS})
include_directories(${DBUS_INCLUDE_DIR} ${DBUS_ARCH_INCLUDE_DIR})
endif()

View file

@ -263,6 +263,22 @@ void CameraGroup::setCameraParameters(float vfov, float aspectRatio)
1.0f / aspectRatio,
_zNear, _zFar);
}
double CameraGroup::getMasterAspectRatio() const
{
if (_cameras.empty())
return 0.0;
const CameraInfo* info = _cameras.front();
const osg::Viewport* viewport = info->camera->getViewport();
if (!viewport) {
return 0.0;
}
return static_cast<double>(viewport->height()) / viewport->width();
}
}
namespace

View file

@ -183,6 +183,11 @@ public:
void buildDistortionCamera(const SGPropertyNode* psNode,
osg::Camera* camera);
/**
* get aspect ratio of master camera's viewport
*/
double getMasterAspectRatio() const;
protected:
CameraList _cameras;
osg::ref_ptr<osgViewer::Viewer> _viewer;

View file

@ -12,6 +12,7 @@
#include "CameraGroup.hxx"
#include "FGEventHandler.hxx"
#include "WindowSystemAdapter.hxx"
#include "renderer.hxx"
#if !defined(X_DISPLAY_MISSING)
#define X_DOUBLE_SCROLL_BUG 1
@ -29,8 +30,6 @@ const int printStatsKey = 2;
FGEventHandler::FGEventHandler() :
idleHandler(0),
drawHandler(0),
windowResizeHandler(0),
keyHandler(0),
mouseClickHandler(0),
mouseMotionHandler(0),
@ -233,8 +232,8 @@ bool FGEventHandler::handle(const osgGA::GUIEventAdapter& ea,
return true;
case osgGA::GUIEventAdapter::RESIZE:
CameraGroup::getDefault()->resized();
if (resizable && windowResizeHandler)
(*windowResizeHandler)(ea.getWindowWidth(), ea.getWindowHeight());
if (resizable)
globals->get_renderer()->resize(ea.getWindowWidth(), ea.getWindowHeight());
return true;
case osgGA::GUIEventAdapter::CLOSE_WINDOW:
case osgGA::GUIEventAdapter::QUIT_APPLICATION:

View file

@ -34,26 +34,6 @@ public:
return idleHandler;
}
void setDrawHandler(fgDrawHandler drawHandler)
{
this->drawHandler = drawHandler;
}
fgDrawHandler getDrawHandler() const
{
return drawHandler;
}
void setWindowResizeHandler(fgWindowResizeHandler windowResizeHandler)
{
this->windowResizeHandler = windowResizeHandler;
}
fgWindowResizeHandler getWindowResizeHandler() const
{
return windowResizeHandler;
}
void setKeyHandler(fgKeyHandler keyHandler)
{
this->keyHandler = keyHandler;
@ -103,8 +83,6 @@ public:
protected:
osg::ref_ptr<osg::Node> _node;
fgIdleHandler idleHandler;
fgDrawHandler drawHandler;
fgWindowResizeHandler windowResizeHandler;
fgKeyHandler keyHandler;
fgMouseClickHandler mouseClickHandler;
fgMouseMotionHandler mouseMotionHandler;

View file

@ -39,16 +39,6 @@ void fgRegisterIdleHandler(fgIdleHandler func)
globals->get_renderer()->getEventHandler()->setIdleHandler(func);
}
void fgRegisterDrawHandler(fgDrawHandler func)
{
globals->get_renderer()->getEventHandler()->setDrawHandler(func);
}
void fgRegisterWindowResizeHandler(fgWindowResizeHandler func)
{
globals->get_renderer()->getEventHandler()->setWindowResizeHandler(func);
}
void fgRegisterKeyHandler(fgKeyHandler func)
{
globals->get_renderer()->getEventHandler()->setKeyHandler(func);

View file

@ -279,11 +279,9 @@ int fgOSMainLoop()
viewer->realize();
while (!viewer->done()) {
fgIdleHandler idleFunc = manipulator->getIdleHandler();
fgDrawHandler drawFunc = manipulator->getDrawHandler();
if (idleFunc)
(*idleFunc)();
if (drawFunc)
(*drawFunc)();
globals->get_renderer()->update();
viewer->frame();
}

View file

@ -556,11 +556,6 @@ static void fgIdleFunction ( void ) {
}
}
static void fgWinResizeFunction(int width, int height)
{
globals->get_renderer()->resize(width, height);
}
static void upper_case_property(const char *name)
{
using namespace simgear;
@ -651,9 +646,7 @@ int fgMainInit( int argc, char **argv ) {
fgOSInit(&argc, argv);
_bootstrap_OSInit++;
fgRegisterWindowResizeHandler( &fgWinResizeFunction );
fgRegisterIdleHandler( &fgIdleFunction );
fgRegisterDrawHandler( &FGRenderer::update );
// Initialize sockets (WinSock needs this)
simgear::Socket::initSockets();

View file

@ -595,15 +595,9 @@ FGRenderer::setupView( void )
stateSet->setAttributeAndModes(new osg::Program, osg::StateAttribute::ON);
}
void
FGRenderer::update()
{
globals->get_renderer()->update(true);
}
// Update all Visuals (redraws anything graphics related)
void
FGRenderer::update( bool refresh_camera_settings ) {
FGRenderer::update( ) {
if (!(_scenery_loaded->getBoolValue() ||
_scenery_override->getBoolValue()))
{
@ -655,12 +649,7 @@ FGRenderer::update( bool refresh_camera_settings ) {
FGViewer *current__view = globals->get_current_view();
// Force update of center dependent values ...
current__view->set_dirty();
if ( refresh_camera_settings ) {
// update view port
resize( _xsize->getIntValue(),
_ysize->getIntValue() );
}
osg::Camera *camera = viewer->getCamera();
bool skyblend = _skyblend->getBoolValue();
@ -777,22 +766,9 @@ FGRenderer::update( bool refresh_camera_settings ) {
CameraGroup::getDefault()->setCameraCullMasks(cullMask);
}
// options.cxx needs to see this for toggle_panel()
// Handle new window size or exposure
void
FGRenderer::resize( int width, int height ) {
// the following breaks aspect-ratio of the main 3D scenery window when 2D panels are moved
// in y direction - causing issues for aircraft with 2D panels (/sim/virtual_cockpit=false).
// Disabling for now. Seems this useful for the pre-OSG time only.
// if ( (!_virtual_cockpit->getBoolValue())
// && fgPanelVisible() && idle_state == 1000 ) {
// view_h = (int)(height * (globals->get_current_panel()->getViewHeight() -
// globals->get_current_panel()->getYOffset()) / 768.0);
// }
FGRenderer::resize( int width, int height )
{
int curWidth = _xsize->getIntValue(),
curHeight = _ysize->getIntValue();
if ((curHeight != height) || (curWidth != width)) {
@ -800,18 +776,6 @@ FGRenderer::resize( int width, int height ) {
_xsize->setIntValue(width);
_ysize->setIntValue(height);
}
// must set view aspect ratio each frame, or initial values are wrong.
// should probably be fixed 'smarter' during view setup.
double aspect = height / (double) width;
// for all views
FGViewMgr *viewmgr = globals->get_viewmgr();
if (viewmgr) {
for ( int i = 0; i < viewmgr->size(); ++i ) {
viewmgr->get_view(i)->set_aspect_ratio(aspect);
}
}
}
bool

View file

@ -51,12 +51,8 @@ public:
void resize(int width, int height );
// calling update( refresh_camera_settings = false ) will not
// touch window or camera settings. This is useful for the tiled
// renderer which needs to set the view frustum itself.
void update( bool refresh_camera_settings);
static void update();
void update();
/** Just pick into the scene and return the pick callbacks on the way ...
*/
bool pick( std::vector<SGSceneryPick>& pickList,

View file

@ -65,7 +65,6 @@ FGViewer::FGViewer( fgViewType Type, bool from_model, int from_model_index,
_pitch_deg(0),
_heading_deg(0),
_scaling_type(FG_SCALING_MAX),
_aspect_ratio(0),
_cameraGroup(CameraGroup::getDefault())
{
_absolute_view_pos = SGVec3d(0, 0, 0);
@ -102,7 +101,7 @@ FGViewer::FGViewer( fgViewType Type, bool from_model, int from_model_index,
} else {
_fov_deg = 55;
}
_aspect_ratio = 1;
_aspect_ratio_multiplier = aspect_ratio_multiplier;
_target_offset_m.x() = target_x_offset_m;
_target_offset_m.y() = target_y_offset_m;
@ -539,18 +538,19 @@ FGViewer::updateDampOutput(double dt)
double
FGViewer::get_h_fov()
{
double aspectRatio = _cameraGroup->getMasterAspectRatio();
switch (_scaling_type) {
case FG_SCALING_WIDTH: // h_fov == fov
return _fov_deg;
case FG_SCALING_MAX:
if (_aspect_ratio < 1.0) {
if (aspectRatio < 1.0) {
// h_fov == fov
return _fov_deg;
} else {
// v_fov == fov
return
atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS)
/ (_aspect_ratio*_aspect_ratio_multiplier))
/ (aspectRatio*_aspect_ratio_multiplier))
* SG_RADIANS_TO_DEGREES * 2;
}
default:
@ -564,18 +564,19 @@ FGViewer::get_h_fov()
double
FGViewer::get_v_fov()
{
double aspectRatio = _cameraGroup->getMasterAspectRatio();
switch (_scaling_type) {
case FG_SCALING_WIDTH: // h_fov == fov
return
atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS)
* (_aspect_ratio*_aspect_ratio_multiplier))
* (aspectRatio*_aspect_ratio_multiplier))
* SG_RADIANS_TO_DEGREES * 2;
case FG_SCALING_MAX:
if (_aspect_ratio < 1.0) {
if (aspectRatio < 1.0) {
// h_fov == fov
return
atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS)
* (_aspect_ratio*_aspect_ratio_multiplier))
* (aspectRatio*_aspect_ratio_multiplier))
* SG_RADIANS_TO_DEGREES * 2;
} else {
// v_fov == fov
@ -671,3 +672,8 @@ FGViewer::update (double dt)
_cameraGroup->setCameraParameters(get_v_fov(), get_aspect_ratio());
}
}
double FGViewer::get_aspect_ratio() const
{
return _cameraGroup->getMasterAspectRatio();
}

View file

@ -215,10 +215,7 @@ public:
virtual double get_h_fov(); // Get horizontal fov, in degrees.
virtual double get_v_fov(); // Get vertical fov, in degrees.
virtual void set_aspect_ratio( double r ) {
_aspect_ratio = r;
}
virtual double get_aspect_ratio() const { return _aspect_ratio; }
virtual double get_aspect_ratio() const;
virtual void set_aspect_ratio_multiplier( double m ) {
_aspect_ratio_multiplier = m;
@ -305,11 +302,6 @@ private:
// the nominal field of view (angle, in degrees)
double _fov_deg;
// Ratio of window width and height; height = width *
// aspect_ratio. This value is automatically calculated based on
// window dimentions.
double _aspect_ratio;
// default = 1.0, this value is user configurable and is
// multiplied into the aspect_ratio to get the actual vertical fov
double _aspect_ratio_multiplier;