Compare commits

..
Author SHA1 Message Date
James Turner 506b9130a8 Adjust where we set the deployment SDK on Mac.
Contrary to the CMake docs, settings this value before project()
seems not to work, whereas setting it after works exactly as
desired.
2015-02-18 10:06:03 +00:00
James Turner 5d1b70a7f2 Force SDK version / C++ library on Mac. 2015-02-13 14:47:45 +00:00
Peter Sadrozinski eff3df57d9 memory reduced tile loading.
- do not save the TileGeometryBin and matcach in the randomObjectCallback
- recreate matcache, and get TileGeometry from scenegraph
- split obj.cxx into three distinct files - loadBTG, load surface geometry, and load tile details
- includes fix for sceneries that have missing materials
2015-02-11 09:04:53 +01:00
Rebecca N. Palmer 2931f3380f Fix UpdateOnceCallback crash (bug 1554/1556/1568)
(cherry picked from commit dc1816bb08)
2015-01-19 15:51:36 +00:00
67 changed files with 411 additions and 1233 deletions
+5 -25
View File
@@ -1,28 +1,13 @@
cmake_minimum_required (VERSION 2.6.4) cmake_minimum_required (VERSION 2.6.4)
if(COMMAND cmake_policy)
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
endif()
include (CheckFunctionExists) include (CheckFunctionExists)
include (CheckIncludeFile) include (CheckIncludeFile)
include (CheckLibraryExists)
include (CheckCXXSourceCompiles) include (CheckCXXSourceCompiles)
include (CheckCXXCompilerFlag) include (CheckCXXCompilerFlag)
project(SimGear)
# using 10.7 because boost requires libc++ and 10.6 doesn't include it # using 10.7 because boost requires libc++ and 10.6 doesn't include it
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7) set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7)
set(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk)
# only relevant for building shared libs but let's set it regardless
set(CMAKE_OSX_RPATH 1)
project(SimGear)
# read 'version' file into a variable (stripping any newlines or spaces) # read 'version' file into a variable (stripping any newlines or spaces)
file(READ version versionFile) file(READ version versionFile)
@@ -181,16 +166,11 @@ if(APPLE)
find_library(COCOA_LIBRARY Cocoa) find_library(COCOA_LIBRARY Cocoa)
endif() endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR
${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
find_package(Threads REQUIRED)
endif()
# Somehow this only works if included before searching for Boost... # Somehow this only works if included before searching for Boost...
include(BoostTestTargets) include(BoostTestTargets)
find_package(Boost REQUIRED) find_package(Boost REQUIRED)
set (BOOST_CXX_FLAGS "-DBOOST_BIMAP_DISABLE_SERIALIZATION") set (BOOST_CXX_FLAGS "-DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_BIMAP_DISABLE_SERIALIZATION")
if(SIMGEAR_HEADLESS) if(SIMGEAR_HEADLESS)
message(STATUS "SimGear mode: HEADLESS") message(STATUS "SimGear mode: HEADLESS")
@@ -208,6 +188,7 @@ else()
endif(SIMGEAR_HEADLESS) endif(SIMGEAR_HEADLESS)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
find_package(Threads REQUIRED)
if (SYSTEM_EXPAT) if (SYSTEM_EXPAT)
message(STATUS "Requested to use system Expat library, forcing SIMGEAR_SHARED to true") message(STATUS "Requested to use system Expat library, forcing SIMGEAR_SHARED to true")
@@ -319,8 +300,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif(CMAKE_COMPILER_IS_GNUCXX) endif(CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# Boost redeclares class members set(WARNING_FLAGS_CXX "-Wall -Wno-overloaded-virtual")
set(WARNING_FLAGS_CXX "-Wall -Wno-overloaded-virtual -Wno-redeclared-class-member")
set(WARNING_FLAGS_C "-Wall") set(WARNING_FLAGS_C "-Wall")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
+30 -68
View File
@@ -44,7 +44,6 @@ namespace canvas
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const std::string GEO = "-geo"; const std::string GEO = "-geo";
const std::string HDG = "hdg";
const std::string Map::TYPE_NAME = "map"; const std::string Map::TYPE_NAME = "map";
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -113,89 +112,39 @@ namespace canvas
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void Map::childAdded(SGPropertyNode* parent, SGPropertyNode* child) void Map::childAdded(SGPropertyNode* parent, SGPropertyNode* child)
{ {
if( boost::ends_with(child->getNameString(), GEO) ) if( !boost::ends_with(child->getNameString(), GEO) )
_geo_nodes[child].reset(new GeoNodePair());
else if( parent != _node && child->getNameString() == HDG )
_hdg_nodes.insert(child);
else
return Element::childAdded(parent, child); return Element::childAdded(parent, child);
_geo_nodes[child].reset(new GeoNodePair());
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void Map::childRemoved(SGPropertyNode* parent, SGPropertyNode* child) void Map::childRemoved(SGPropertyNode* parent, SGPropertyNode* child)
{ {
if( boost::ends_with(child->getNameString(), GEO) ) if( !boost::ends_with(child->getNameString(), GEO) )
return Element::childRemoved(parent, child);
// TODO remove from other node // TODO remove from other node
_geo_nodes.erase(child); _geo_nodes.erase(child);
else if( parent != _node && child->getName() == HDG )
{
_hdg_nodes.erase(child);
// Remove rotation matrix (tf[0]) and return to element always being
// oriented upwards (or any orientation inside other matrices).
child->getParent()->removeChild("tf", 0);
}
else
return Element::childRemoved(parent, child);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void Map::valueChanged(SGPropertyNode* child) void Map::valueChanged(SGPropertyNode * child)
{
if( child->getParent() != _node )
{ {
const std::string& name = child->getNameString(); const std::string& name = child->getNameString();
if( boost::ends_with(name, GEO) ) if( !boost::ends_with(name, GEO) )
return geoNodeChanged(child);
else if( name == HDG )
return hdgNodeChanged(child);
}
return Group::valueChanged(child); return Group::valueChanged(child);
}
//----------------------------------------------------------------------------
void Map::childChanged(SGPropertyNode* child)
{
if( child->getParent() != _node )
return Group::childChanged(child);
if( child->getNameString() == "ref-lat"
|| child->getNameString() == "ref-lon" )
_projection->setWorldPosition( _node->getDoubleValue("ref-lat"),
_node->getDoubleValue("ref-lon") );
else if( child->getNameString() == HDG )
{
_projection->setOrientation(child->getFloatValue());
for( NodeSet::iterator it = _hdg_nodes.begin();
it != _hdg_nodes.end();
++it )
hdgNodeChanged(*it);
}
else if( child->getNameString() == "range" )
_projection->setRange(child->getDoubleValue());
else if( child->getNameString() == "screen-range" )
_projection->setScreenRange(child->getDoubleValue());
else
return Group::childChanged(child);
_projection_dirty = true;
}
//----------------------------------------------------------------------------
void Map::geoNodeChanged(SGPropertyNode* child)
{
GeoNodes::iterator it_geo_node = _geo_nodes.find(child); GeoNodes::iterator it_geo_node = _geo_nodes.find(child);
if( it_geo_node == _geo_nodes.end() ) if( it_geo_node == _geo_nodes.end() )
LOG_GEO_RET("GeoNode not found!") LOG_GEO_RET("geo node not found!")
GeoNodePair* geo_node = it_geo_node->second.get(); GeoNodePair* geo_node = it_geo_node->second.get();
geo_node->setDirty(); geo_node->setDirty();
if( !(geo_node->getStatus() & GeoNodePair::INCOMPLETE) ) if( geo_node->getStatus() & GeoNodePair::INCOMPLETE )
return; {
// Detect lat, lon tuples... // Detect lat, lon tuples...
GeoCoord coord = parseGeoCoord(child->getStringValue()); GeoCoord coord = parseGeoCoord(child->getStringValue());
int index_other = -1; int index_other = -1;
@@ -214,7 +163,6 @@ namespace canvas
LOG_GEO_RET("Invalid geo coord") LOG_GEO_RET("Invalid geo coord")
} }
const std::string& name = child->getNameString();
SGPropertyNode *other = child->getParent()->getChild(name, index_other); SGPropertyNode *other = child->getParent()->getChild(name, index_other);
if( !other ) if( !other )
return; return;
@@ -241,14 +189,28 @@ namespace canvas
// Set name for resulting screen coordinate nodes // Set name for resulting screen coordinate nodes
geo_node->setTargetName( name.substr(0, name.length() - GEO.length()) ); geo_node->setTargetName( name.substr(0, name.length() - GEO.length()) );
} }
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void Map::hdgNodeChanged(SGPropertyNode* child) void Map::childChanged(SGPropertyNode * child)
{ {
child->getParent()->setFloatValue( if( child->getParent() != _node )
"tf[0]/rot", return Group::childChanged(child);
SGMiscf::deg2rad(child->getFloatValue() - _projection->orientation())
); if( child->getNameString() == "ref-lat"
|| child->getNameString() == "ref-lon" )
_projection->setWorldPosition( _node->getDoubleValue("ref-lat"),
_node->getDoubleValue("ref-lon") );
else if( child->getNameString() == "hdg" )
_projection->setOrientation(child->getFloatValue());
else if( child->getNameString() == "range" )
_projection->setRange(child->getDoubleValue());
else if( child->getNameString() == "screen-range" )
_projection->setScreenRange(child->getDoubleValue());
else
return Group::childChanged(child);
_projection_dirty = true;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
+1 -9
View File
@@ -24,7 +24,6 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>
namespace simgear namespace simgear
{ {
@@ -60,18 +59,14 @@ namespace canvas
typedef boost::unordered_map< SGPropertyNode*, typedef boost::unordered_map< SGPropertyNode*,
boost::shared_ptr<GeoNodePair> boost::shared_ptr<GeoNodePair>
> GeoNodes; > GeoNodes;
typedef boost::unordered_set<SGPropertyNode*> NodeSet;
GeoNodes _geo_nodes; GeoNodes _geo_nodes;
NodeSet _hdg_nodes;
boost::shared_ptr<HorizontalProjection> _projection; boost::shared_ptr<HorizontalProjection> _projection;
bool _projection_dirty; bool _projection_dirty;
struct GeoCoord struct GeoCoord
{ {
GeoCoord(): GeoCoord():
type(INVALID), type(INVALID)
value(0)
{} {}
enum enum
{ {
@@ -82,9 +77,6 @@ namespace canvas
double value; double value;
}; };
void geoNodeChanged(SGPropertyNode * child);
void hdgNodeChanged(SGPropertyNode * child);
GeoCoord parseGeoCoord(const std::string& val) const; GeoCoord parseGeoCoord(const std::string& val) const;
}; };
+2 -17
View File
@@ -159,12 +159,8 @@ namespace canvas
if( empty() ) if( empty() )
return pos; return pos;
#if OSG_VERSION_LESS_THAN(3,3,5)
GlyphQuads::Coords2 const& coords = _quads->_coords; GlyphQuads::Coords2 const& coords = _quads->_coords;
#else
GlyphQuads::Coords2 refCoords = _quads->_coords;
GlyphQuads::Coords2::element_type &coords = *refCoords.get();
#endif
size_t global_i = _begin + i; size_t global_i = _begin + i;
if( global_i == _begin ) if( global_i == _begin )
@@ -198,12 +194,7 @@ namespace canvas
return cursorPos(0); return cursorPos(0);
GlyphQuads::Glyphs const& glyphs = _quads->_glyphs; GlyphQuads::Glyphs const& glyphs = _quads->_glyphs;
#if OSG_VERSION_LESS_THAN(3,3,5)
GlyphQuads::Coords2 const& coords = _quads->_coords; GlyphQuads::Coords2 const& coords = _quads->_coords;
#else
GlyphQuads::Coords2 refCoords = _quads->_coords;
GlyphQuads::Coords2::element_type &coords = *refCoords.get();
#endif
float const HIT_FRACTION = 0.6; float const HIT_FRACTION = 0.6;
float const character_width = _text->getCharacterHeight() float const character_width = _text->getCharacterHeight()
@@ -636,13 +627,7 @@ namespace canvas
const GlyphQuads& quads = _textureGlyphQuadMap.begin()->second; const GlyphQuads& quads = _textureGlyphQuadMap.begin()->second;
const GlyphQuads::Glyphs& glyphs = quads._glyphs; const GlyphQuads::Glyphs& glyphs = quads._glyphs;
#if OSG_VERSION_LESS_THAN(3,3,5) const GlyphQuads::Coords2& coords = quads._coords;
GlyphQuads::Coords2 const& coords = quads._coords;
#else
GlyphQuads::Coords2 refCoords = quads._coords;
GlyphQuads::Coords2::element_type &coords = *refCoords.get();
#endif
const GlyphQuads::LineNumbers& line_numbers = quads._lineNumbers; const GlyphQuads::LineNumbers& line_numbers = quads._lineNumbers;
float wr = _characterHeight / getCharacterAspectRatio(); float wr = _characterHeight / getCharacterAspectRatio();
+11 -28
View File
@@ -34,10 +34,7 @@ namespace canvas
public: public:
struct ScreenPosition struct ScreenPosition
{ {
ScreenPosition(): ScreenPosition() {}
x(0),
y(0)
{}
ScreenPosition(double x, double y): ScreenPosition(double x, double y):
x(x), x(x),
@@ -70,11 +67,8 @@ namespace canvas
public: public:
HorizontalProjection(): HorizontalProjection():
_ref_lat(0), _cos_rot(1),
_ref_lon(0), _sin_rot(0),
_angle(0),
_cos_angle(1),
_sin_angle(0),
_range(5) _range(5)
{ {
setScreenRange(200); setScreenRange(200);
@@ -94,19 +88,9 @@ namespace canvas
*/ */
void setOrientation(float hdg) void setOrientation(float hdg)
{ {
_angle = hdg;
hdg = SGMiscf::deg2rad(hdg); hdg = SGMiscf::deg2rad(hdg);
_sin_angle = sin(hdg); _sin_rot = sin(hdg);
_cos_angle = cos(hdg); _cos_rot = cos(hdg);
}
/**
* Get orientation/heading of the projection (in degree)
*/
float orientation() const
{
return _angle;
} }
void setRange(double range) void setRange(double range)
@@ -130,8 +114,8 @@ namespace canvas
pos.y *= scale; pos.y *= scale;
return ScreenPosition return ScreenPosition
( (
_cos_angle * pos.x - _sin_angle * pos.y, _cos_rot * pos.x - _sin_rot * pos.y,
-_sin_angle * pos.x - _cos_angle * pos.y -_sin_rot * pos.x - _cos_rot * pos.y
); );
} }
@@ -145,11 +129,10 @@ namespace canvas
*/ */
virtual ScreenPosition project(double lat, double lon) const = 0; virtual ScreenPosition project(double lat, double lon) const = 0;
double _ref_lat, ///<! Reference latitude (radian) double _ref_lat,
_ref_lon, ///<! Reference latitude (radian) _ref_lon,
_angle, ///<! Map rotation angle (degree) _cos_rot,
_cos_angle, _sin_rot,
_sin_angle,
_range; _range;
}; };
+1 -1
View File
@@ -22,7 +22,7 @@
* $Id$ * $Id$
**************************************************************************/ **************************************************************************/
#include <cmath> #include <math.h>
#include "jupiter.hxx" #include "jupiter.hxx"
+1 -1
View File
@@ -22,7 +22,7 @@
* $Id$ * $Id$
**************************************************************************/ **************************************************************************/
#include <cmath> #include <math.h>
#include "mars.hxx" #include "mars.hxx"
+1 -1
View File
@@ -22,7 +22,7 @@
* $Id$ * $Id$
**************************************************************************/ **************************************************************************/
#include <cmath> #include <math.h>
#include "mercury.hxx" #include "mercury.hxx"
+1 -1
View File
@@ -25,7 +25,7 @@
#ifdef __BORLANDC__ #ifdef __BORLANDC__
# define exception c_exception # define exception c_exception
#endif #endif
#include <cmath> #include <math.h>
#include "neptune.hxx" #include "neptune.hxx"
+1 -1
View File
@@ -22,7 +22,7 @@
* $Id$ * $Id$
**************************************************************************/ **************************************************************************/
#include <cmath> #include <math.h>
#include "saturn.hxx" #include "saturn.hxx"
+1 -1
View File
@@ -22,7 +22,7 @@
* $Id$ * $Id$
**************************************************************************/ **************************************************************************/
#include <cmath> #include <math.h>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
+1 -1
View File
@@ -22,7 +22,7 @@
* $Id$ * $Id$
**************************************************************************/ **************************************************************************/
#include <cmath> #include <math.h>
#include "uranus.hxx" #include "uranus.hxx"
+1 -1
View File
@@ -22,7 +22,7 @@
* $Id$ * $Id$
**************************************************************************/ **************************************************************************/
#include <cmath> #include <math.h>
#include "venus.hxx" #include "venus.hxx"
+4 -10
View File
@@ -239,6 +239,7 @@ void SVNDirectory::deleteChildByName(const std::string& nm)
{ {
DAVResource* child = dav->childWithName(nm); DAVResource* child = dav->childWithName(nm);
if (!child) { if (!child) {
// std::cerr << "ZZZ: deleteChildByName: unknown:" << nm << std::endl;
return; return;
} }
@@ -246,24 +247,17 @@ void SVNDirectory::deleteChildByName(const std::string& nm)
if (child->isCollection()) { if (child->isCollection()) {
Dir d(path); Dir d(path);
bool ok = d.remove(true); d.remove(true);
if (!ok) {
SG_LOG(SG_NETWORK, SG_ALERT, "SVNDirectory::deleteChildByName: failed to remove dir:"
<< nm << " at path:\n\t" << path);
}
DirectoryList::iterator it = findChildDir(nm); DirectoryList::iterator it = findChildDir(nm);
if (it != _children.end()) { if (it != _children.end()) {
SVNDirectory* c = *it; SVNDirectory* c = *it;
// std::cout << "YYY: deleting SVNDirectory for:" << nm << std::endl;
delete c; delete c;
_children.erase(it); _children.erase(it);
} }
} else { } else {
bool ok = path.remove(); path.remove();
if (!ok) {
SG_LOG(SG_NETWORK, SG_ALERT, "SVNDirectory::deleteChildByName: failed to remove path:" << nm
<< " at path:\n\t" << path);
}
} }
dav->removeChild(child); dav->removeChild(child);
-5
View File
@@ -251,11 +251,6 @@ NetChannelPoller::removeChannel(NetChannel* channel)
assert(channel->poller == this); assert(channel->poller == this);
channel->poller = NULL; channel->poller = NULL;
// portability: MSVC throws assertion failure when empty
if (channels.empty()) {
return;
}
ChannelList::iterator it = channels.begin(); ChannelList::iterator it = channels.begin();
for (; it != channels.end(); ++it) { for (; it != channels.end(); ++it) {
if (*it == channel) { if (*it == channel) {
-1
View File
@@ -27,7 +27,6 @@
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#include <algorithm>
namespace simgear { namespace simgear {
-1
View File
@@ -32,7 +32,6 @@
#include <cstring> #include <cstring>
#include <cstdlib> // for atoi #include <cstdlib> // for atoi
#include <algorithm>
using std::string; using std::string;
+4 -6
View File
@@ -379,8 +379,6 @@ class TestServer : public NetChannel
public: public:
TestServer() TestServer()
{ {
Socket::initSockets();
open(); open();
bind(NULL, 2000); // localhost, any port bind(NULL, 2000); // localhost, any port
listen(5); listen(5);
@@ -416,14 +414,14 @@ TestServer testServer;
void waitForComplete(HTTP::Client* cl, TestRequest* tr) void waitForComplete(HTTP::Client* cl, TestRequest* tr)
{ {
SGTimeStamp start(SGTimeStamp::now()); SGTimeStamp start(SGTimeStamp::now());
while (start.elapsedMSec() < 10000) { while (start.elapsedMSec() < 1000) {
cl->update(); cl->update();
testServer.poll(); testServer.poll();
if (tr->complete) { if (tr->complete) {
return; return;
} }
SGTimeStamp::sleepForMSec(15); SGTimeStamp::sleepForMSec(1);
} }
cerr << "timed out" << endl; cerr << "timed out" << endl;
@@ -432,14 +430,14 @@ void waitForComplete(HTTP::Client* cl, TestRequest* tr)
void waitForFailed(HTTP::Client* cl, TestRequest* tr) void waitForFailed(HTTP::Client* cl, TestRequest* tr)
{ {
SGTimeStamp start(SGTimeStamp::now()); SGTimeStamp start(SGTimeStamp::now());
while (start.elapsedMSec() < 10000) { while (start.elapsedMSec() < 1000) {
cl->update(); cl->update();
testServer.poll(); testServer.poll();
if (tr->failed) { if (tr->failed) {
return; return;
} }
SGTimeStamp::sleepForMSec(15); SGTimeStamp::sleepForMSec(1);
} }
cerr << "timed out waiting for failure" << endl; cerr << "timed out waiting for failure" << endl;
+1 -1
View File
@@ -79,7 +79,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <cmath> #include <math.h>
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/sg_inlines.h> #include <simgear/sg_inlines.h>
+1 -1
View File
@@ -26,7 +26,7 @@
#endif #endif
#include <cmath> #include <math.h>
#include <simgear/magvar/magvar.hxx> #include <simgear/magvar/magvar.hxx>
#include <simgear/math/SGMath.hxx> #include <simgear/math/SGMath.hxx>
+1 -1
View File
@@ -2,7 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <cmath> #include <math.h>
#include <simgear/constants.h> #include <simgear/constants.h>
-4
View File
@@ -37,10 +37,6 @@ set(SOURCES
gzcontainerfile.cxx gzcontainerfile.cxx
) )
if (WINDOWS)
list(APPEND HEADERS sgversionhelpers.hxx)
endif()
if (APPLE) if (APPLE)
list(APPEND SOURCES CocoaHelpers.mm) list(APPEND SOURCES CocoaHelpers.mm)
endif() endif()
-4
View File
@@ -141,11 +141,7 @@ int main(int argc, char* argv[])
// add // add
pc.add("/opt/local"); pc.add("/opt/local");
#ifdef _WIN32
COMPARE(pc.str(), std::string("/usr/local/include/;/opt/local"));
#else
COMPARE(pc.str(), std::string("/usr/local/include/:/opt/local")); COMPARE(pc.str(), std::string("/usr/local/include/:/opt/local"));
#endif
// concat // concat
SGPath pd = pb; SGPath pd = pb;
-1
View File
@@ -382,7 +382,6 @@ bool Dir::remove(bool recursive)
if (recursive) { if (recursive) {
if (!removeChildren()) { if (!removeChildren()) {
SG_LOG(SG_IO, SG_WARN, "Dir at:" << _path << " failed to remove children");
return false; return false;
} }
} // of recursive deletion } // of recursive deletion
+13 -62
View File
@@ -57,9 +57,6 @@ static const char sgSearchPathSep = ':';
#ifdef _WIN32 #ifdef _WIN32
#include <ShlObj.h> // for CSIDL #include <ShlObj.h> // for CSIDL
// TODO: replace this include file with the official <versionhelpers.h> header
// included in the Windows 8.1 SDK
#include "sgversionhelpers.hxx"
static SGPath pathForCSIDL(int csidl, const SGPath& def) static SGPath pathForCSIDL(int csidl, const SGPath& def)
{ {
@@ -83,42 +80,6 @@ static SGPath pathForCSIDL(int csidl, const SGPath& def)
return def; return def;
} }
static SGPath pathForKnownFolder(REFKNOWNFOLDERID folderId, const SGPath& def)
{
typedef HRESULT (WINAPI*PSHGKFP)(REFKNOWNFOLDERID, DWORD, HANDLE, PWSTR*);
HINSTANCE shellDll = LoadLibrary(TEXT("shell32"));
if (shellDll != NULL) {
PSHGKFP pSHGetKnownFolderPath = (PSHGKFP) GetProcAddress(shellDll, "SHGetKnownFolderPath");
if (pSHGetKnownFolderPath != NULL) {
// system call will allocate dynamic memory... which we must release when done
wchar_t* localFolder = 0;
if (pSHGetKnownFolderPath(folderId, KF_FLAG_DEFAULT_PATH, NULL, &localFolder) == S_OK) {
// copy into local memory
char path[MAX_PATH];
size_t len;
if (wcstombs_s(&len, path, localFolder, MAX_PATH) != S_OK) {
path[0] = '\0';
SG_LOG(SG_GENERAL, SG_WARN, "WCS to MBS failed");
}
SGPath folder_path = SGPath(path, def.getPermissionChecker());
// release dynamic memory
CoTaskMemFree(static_cast<void*>(localFolder));
return folder_path;
}
}
FreeLibrary(shellDll);
}
return def;
}
#elif __APPLE__ #elif __APPLE__
// defined in CocoaHelpers.mm // defined in CocoaHelpers.mm
@@ -743,35 +704,20 @@ SGPath SGPath::standardLocation(StandardLocation type, const SGPath& def)
{ {
case HOME: case HOME:
return home(def); return home(def);
#ifdef _WIN32 #ifdef _WIN32
case DESKTOP: case DESKTOP:
if (IsWindowsVistaOrGreater())
return pathForKnownFolder(FOLDERID_Desktop, def);
return pathForCSIDL(CSIDL_DESKTOPDIRECTORY, def); return pathForCSIDL(CSIDL_DESKTOPDIRECTORY, def);
case DOWNLOADS: case DOWNLOADS:
if (IsWindowsVistaOrGreater()) // TODO use KnownFolders
return pathForKnownFolder(FOLDERID_Downloads, def); // http://msdn.microsoft.com/en-us/library/bb776911%28v=vs.85%29.aspx
if( !def.isNull() )
if (!def.isNull())
return def; return def;
return pathForCSIDL(CSIDL_DESKTOPDIRECTORY, def); return pathForCSIDL(CSIDL_DESKTOPDIRECTORY, def);
case DOCUMENTS: case DOCUMENTS:
if (IsWindowsVistaOrGreater())
return pathForKnownFolder(FOLDERID_Documents, def);
return pathForCSIDL(CSIDL_MYDOCUMENTS, def); return pathForCSIDL(CSIDL_MYDOCUMENTS, def);
case PICTURES: case PICTURES:
if (IsWindowsVistaOrGreater())
return pathForKnownFolder(FOLDERID_Pictures, def);
return pathForCSIDL(CSIDL_MYPICTURES, def); return pathForCSIDL(CSIDL_MYPICTURES, def);
#elif __APPLE__ #elif __APPLE__
// since this is C++, we can't include NSPathUtilities.h to access the enum // since this is C++, we can't include NSPathUtilities.h to access the enum
// values, so hard-coding them here (they are stable, don't worry) // values, so hard-coding them here (they are stable, don't worry)
@@ -810,15 +756,20 @@ SGPath SGPath::fromEnv(const char* name, const SGPath& def)
return def; return def;
} }
#ifdef _WIN32
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
SGPath SGPath::home(const SGPath& def) SGPath SGPath::home(const SGPath& def)
{ {
#ifdef _WIN32 // TODO
return fromEnv("USERPROFILE", def); return def;
#else
return fromEnv("HOME", def);
#endif
} }
#else
//------------------------------------------------------------------------------
SGPath SGPath::home(const SGPath& def)
{
return fromEnv("HOME", def);
}
#endif
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
SGPath SGPath::desktop(const SGPath& def) SGPath SGPath::desktop(const SGPath& def)
-122
View File
@@ -1,122 +0,0 @@
// Clean drop-in replacement for the versionhelpers.h header
//
// Copyright (C) 2015 Alessandro Menti <alessandro.menti@hotmail.it>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifndef SG_VERSIONHELPERS_HXX_
#define SG_VERSIONHELPERS_HXX_
#include <sdkddkver.h>
#ifdef __cplusplus
#define VERSIONHELPERAPI inline bool
#else
#define VERSIONHELPERAPI FORCEINLINE BOOL
#endif // __cplusplus
/* Windows 8/8.1 version numbers, not defined in the Windows 7 SDK. */
#ifndef _WIN32_WINNT_WIN8
#define _WIN32_WINNT_WIN8 0x0602
#endif
#ifndef _WIN32_WINNT_WINBLUE
#define _WIN32_WINNT_WINBLUE 0x0603
#endif
VERSIONHELPERAPI IsWindowsVersionOrGreater(WORD wMajorVersion,
WORD wMinorVersion, WORD wServicePackMajor) {
OSVERSIONINFOEXW osVersionInfo;
DWORDLONG dwlConditionMask = 0;
ZeroMemory(&osVersionInfo, sizeof(osVersionInfo));
osVersionInfo.dwOSVersionInfoSize = sizeof(osVersionInfo);
osVersionInfo.dwMajorVersion = wMajorVersion;
osVersionInfo.dwMinorVersion = wMinorVersion;
osVersionInfo.wServicePackMajor = wServicePackMajor;
VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION,
VER_GREATER_EQUAL);
VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION,
VER_GREATER_EQUAL);
VER_SET_CONDITION(dwlConditionMask, VER_SERVICEPACKMAJOR,
VER_GREATER_EQUAL);
return VerifyVersionInfoW(&osVersionInfo, VER_MAJORVERSION
| VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask);
}
VERSIONHELPERAPI IsWindowsXPOrGreater() {
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP),
LOBYTE(_WIN32_WINNT_WINXP), 0);
}
VERSIONHELPERAPI IsWindowsXPSP1OrGreater() {
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP),
LOBYTE(_WIN32_WINNT_WINXP), 1);
}
VERSIONHELPERAPI IsWindowsXPSP2OrGreater() {
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP),
LOBYTE(_WIN32_WINNT_WINXP), 2);
}
VERSIONHELPERAPI IsWindowsXPSP3OrGreater() {
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP),
LOBYTE(_WIN32_WINNT_WINXP), 3);
}
VERSIONHELPERAPI IsWindowsVistaOrGreater() {
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA),
LOBYTE(_WIN32_WINNT_VISTA), 0);
}
VERSIONHELPERAPI IsWindowsVistaSP1OrGreater() {
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA),
LOBYTE(_WIN32_WINNT_VISTA), 1);
}
VERSIONHELPERAPI IsWindowsVistaSP2OrGreater() {
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA),
LOBYTE(_WIN32_WINNT_VISTA), 2);
}
VERSIONHELPERAPI IsWindows7OrGreater() {
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7),
LOBYTE(_WIN32_WINNT_WIN7), 0);
}
VERSIONHELPERAPI IsWindows7SP1OrGreater() {
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7),
LOBYTE(_WIN32_WINNT_WIN7), 1);
}
VERSIONHELPERAPI IsWindows8OrGreater() {
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8),
LOBYTE(_WIN32_WINNT_WIN8), 0);
}
VERSIONHELPERAPI IsWindows8Point1OrGreater() {
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE),
LOBYTE(_WIN32_WINNT_WINBLUE), 0);
}
VERSIONHELPERAPI IsWindowsServer() {
OSVERSIONINFOEXW osVersionInfo;
DWORDLONG dwlConditionMask = 0;
ZeroMemory(&osVersionInfo, sizeof(osVersionInfo));
osVersionInfo.dwOSVersionInfoSize = sizeof(osVersionInfo);
osVersionInfo.wProductType = VER_NT_WORKSTATION;
VER_SET_CONDITION(dwlConditionMask, VER_PRODUCT_TYPE, VER_EQUAL);
return !VerifyVersionInfoW(&osVersionInfo, VER_PRODUCT_TYPE,
dwlConditionMask);
}
#endif // SG_VERSIONHELPERS_HXX_
-1
View File
@@ -23,7 +23,6 @@
#include <ctype.h> #include <ctype.h>
#include <cstring> #include <cstring>
#include <sstream> #include <sstream>
#include <algorithm>
#include "strutils.hxx" #include "strutils.hxx"
+1 -1
View File
@@ -4,7 +4,6 @@ include (SimGearComponent)
set(HEADERS set(HEADERS
naref.h naref.h
nasal.h nasal.h
iolib.h
) )
set(SOURCES set(SOURCES
@@ -27,6 +26,7 @@ set(SOURCES
vector.c vector.c
code.h code.h
data.h data.h
iolib.h
parse.h parse.h
) )
+8
View File
@@ -66,6 +66,14 @@ namespace nasal
void GhostMetadata::addDerived(const GhostMetadata* derived) void GhostMetadata::addDerived(const GhostMetadata* derived)
{ {
assert(derived); assert(derived);
SG_LOG
(
SG_NASAL,
SG_INFO,
"Ghost::addDerived: " << _name_strong << " -> "
<< derived->_name_strong
);
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@@ -39,12 +39,6 @@ static void runNumTests( double (TestContext::*test_double)(const std::string&),
BOOST_CHECK_EQUAL((c.*test_int)("0x755"), 0x755); BOOST_CHECK_EQUAL((c.*test_int)("0x755"), 0x755);
BOOST_CHECK_EQUAL((c.*test_int)("0x055"), 0x55); BOOST_CHECK_EQUAL((c.*test_int)("0x055"), 0x55);
BOOST_CHECK_EQUAL((c.*test_int)("-0x155"), -0x155); BOOST_CHECK_EQUAL((c.*test_int)("-0x155"), -0x155);
BOOST_CHECK_CLOSE((c.*test_double)("2.000000953656983160"),
2.000000953656983160, 1e-5);
/* this value has bit pattern 0x400000007fff6789L,
* so will look like a pointer if the endianness is set wrong
* (see naref.h, data.h)*/
} }
BOOST_AUTO_TEST_CASE( parse_num ) BOOST_AUTO_TEST_CASE( parse_num )
-6
View File
@@ -142,9 +142,6 @@ naRef naIOGhost(naContext c, FILE* f)
return naNewGhost(c, &naIOGhostType, ghost); return naNewGhost(c, &naIOGhostType, ghost);
} }
#if SG_NASAL_UNRESTRICTED_OPEN
// Allows unrestricted file access, which would be a security hole
// Replaced by the one in flightgear src/Scripting/NasalSys.cxx
static naRef f_open(naContext c, naRef me, int argc, naRef* args) static naRef f_open(naContext c, naRef me, int argc, naRef* args)
{ {
FILE* f; FILE* f;
@@ -155,7 +152,6 @@ static naRef f_open(naContext c, naRef me, int argc, naRef* args)
if(!f) naRuntimeError(c, strerror(errno)); if(!f) naRuntimeError(c, strerror(errno));
return naIOGhost(c, f); return naIOGhost(c, f);
} }
#endif
// frees buffer before tossing an error // frees buffer before tossing an error
static int getcguard(naContext ctx, FILE* f, void* buf) static int getcguard(naContext ctx, FILE* f, void* buf)
@@ -248,9 +244,7 @@ static naCFuncItem funcs[] = {
{ "seek", f_seek }, { "seek", f_seek },
{ "tell", f_tell }, { "tell", f_tell },
{ "flush", f_flush }, { "flush", f_flush },
#if SG_NASAL_UNRESTRICTED_OPEN
{ "open", f_open }, { "open", f_open },
#endif
{ "readln", f_readln }, { "readln", f_readln },
{ "stat", f_stat }, { "stat", f_stat },
{ 0 } { 0 }
+1 -6
View File
@@ -1,8 +1,5 @@
#ifndef _IOLIB_H #ifndef _IOLIB_H
#define _IOLIB_H #define _IOLIB_H
#ifdef __cplusplus
extern "C" {
#endif
#include "nasal.h" #include "nasal.h"
@@ -36,7 +33,5 @@ extern struct naIOType naStdIOType;
// Defined in iolib.c, there is no "library" header to put this in // Defined in iolib.c, there is no "library" header to put this in
naRef naIOGhost(naContext c, FILE* f); naRef naIOGhost(naContext c, FILE* f);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // _IOLIB_H #endif // _IOLIB_H
+15 -18
View File
@@ -1,31 +1,28 @@
#ifndef _NAREF_H #ifndef _NAREF_H
#define _NAREF_H #define _NAREF_H
/* Rather than play elaborate and complicated games with
* platform-dependent endianness headers, just detect the platforms we
* support. This list is simpler and smaller, yet still quite
* complete. */
#if (defined(__x86_64) && defined(__linux__)) || defined(__sparcv9) || \ #if (defined(__x86_64) && defined(__linux__)) || defined(__sparcv9) || \
defined(__powerpc64__) defined(__powerpc64__)
/* NASAL_NAN64 mode requires 64 bit pointers that only use the /* Win64 and Irix should work with this too, but have not been
* lower 48 bits; Win64 and Irix should work with this too, but * tested */
* have not been tested */
# define NASAL_NAN64 # define NASAL_NAN64
#elif defined(__BYTE_ORDER__) #elif defined(_M_IX86) || defined(i386) || defined(__x86_64) || \
/* GCC and Clang define these (as a builtin, while
* __LITTLE_ENDIAN__ requires a header), MSVC doesn't */
# if __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__
# define NASAL_LE
# elif __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
# define NASAL_BE
# else
# error Unrecognized endianness
# endif
#elif defined(_M_IX86) || defined(__i386) || defined(__x86_64) || \
defined(__ia64__) || defined(_M_IA64) || defined(__ARMEL__) || \ defined(__ia64__) || defined(_M_IA64) || defined(__ARMEL__) || \
defined(_M_X64) || defined(_M_ARM) defined(_M_X64) || defined(__alpha__) || \
(defined(__sh__) && defined(__LITTLE_ENDIAN__))
# define NASAL_LE # define NASAL_LE
#elif defined(__sparc) || defined(__ARMEB__) || \ #elif defined(__sparc) || defined(__ppc__) || defined(__PPC) || \
defined(__hppa__) || defined(__s390__) || defined(__s390x__) defined (__powerpc__) || defined (__powerpc64__) || defined (__alpha__) || \
defined(__mips) || defined(__ARMEB__) || \
defined(__hppa__) || defined(__s390__) || defined(__s390x__) || \
(defined(__sh__) && !defined(__LITTLE_ENDIAN__))
# define NASAL_BE # define NASAL_BE
#else #else
# error Unknown endianness # error Unrecognized CPU architecture
#endif #endif
typedef union { typedef union {
-12
View File
@@ -26,15 +26,3 @@ if(ENABLE_PKGUTIL)
add_executable(sg_pkgutil pkgutil.cxx) add_executable(sg_pkgutil pkgutil.cxx)
target_link_libraries(sg_pkgutil ${TEST_LIBS}) target_link_libraries(sg_pkgutil ${TEST_LIBS})
endif() endif()
if(ENABLE_TESTS)
add_executable(catalog_test CatalogTest.cxx)
target_link_libraries(catalog_test ${TEST_LIBS})
set_target_properties(catalog_test PROPERTIES
COMPILE_DEFINITIONS "SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"" )
add_test(catalog_test ${EXECUTABLE_OUTPUT_PATH}/catalog_test)
endif(ENABLE_TESTS)
+22 -114
View File
@@ -36,36 +36,7 @@ namespace simgear {
namespace pkg { namespace pkg {
bool checkVersion(const std::string& aVersion, SGPropertyNode_ptr props) CatalogList static_catalogs;
{
BOOST_FOREACH(SGPropertyNode* v, props->getChildren("version")) {
std::string s(v->getStringValue());
if (s== aVersion) {
return true;
}
// allow 3.5.* to match any of 3.5.0, 3.5.1rc1, 3.5.11 or so on
if (strutils::ends_with(s, ".*")) {
size_t lastDot = aVersion.rfind('.');
std::string ver = aVersion.substr(0, lastDot);
if (ver == s.substr(0, s.length() - 2)) {
return true;
}
}
}
return false;
}
std::string redirectUrlForVersion(const std::string& aVersion, SGPropertyNode_ptr props)
{
BOOST_FOREACH(SGPropertyNode* v, props->getChildren("alternate-version")) {
if (v->getStringValue("version") == aVersion) {
return v->getStringValue("url");
}
}
return std::string();
}
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@@ -76,9 +47,6 @@ public:
HTTP::Request(aUrl), HTTP::Request(aUrl),
m_owner(aOwner) m_owner(aOwner)
{ {
// refreshing
m_owner->changeStatus(Delegate::FAIL_IN_PROGRESS);
} }
protected: protected:
@@ -110,23 +78,9 @@ protected:
if (!checkVersion(ver, props)) { if (!checkVersion(ver, props)) {
SG_LOG(SG_GENERAL, SG_WARN, "downloaded catalog " << m_owner->url() << ", version mismatch:\n\t" SG_LOG(SG_GENERAL, SG_WARN, "downloaded catalog " << m_owner->url() << ", version mismatch:\n\t"
<< props->getStringValue("version") << " vs required " << ver); << props->getStringValue("version") << " vs required " << ver);
// check for a version redirect entry
std::string url = redirectUrlForVersion(ver, props);
if (!url.empty()) {
SG_LOG(SG_GENERAL, SG_WARN, "redirecting from " << m_owner->url() <<
" to \n\t" << url);
// update the URL and kick off a new request
m_owner->m_url = url;
Downloader* dl = new Downloader(m_owner, url);
m_owner->root()->makeHTTPRequest(dl);
} else {
m_owner->refreshComplete(Delegate::FAIL_VERSION); m_owner->refreshComplete(Delegate::FAIL_VERSION);
}
return; return;
} // of version check failed }
// cache the catalog data, now we have a valid install root // cache the catalog data, now we have a valid install root
Dir d(m_owner->installRoot()); Dir d(m_owner->installRoot());
@@ -138,10 +92,19 @@ protected:
time(&m_owner->m_retrievedTime); time(&m_owner->m_retrievedTime);
m_owner->writeTimestamp(); m_owner->writeTimestamp();
m_owner->refreshComplete(Delegate::CATALOG_REFRESHED); m_owner->refreshComplete(Delegate::FAIL_SUCCESS);
} }
private: private:
bool checkVersion(const std::string& aVersion, SGPropertyNode* aProps)
{
BOOST_FOREACH(SGPropertyNode* v, aProps->getChildren("version")) {
if (v->getStringValue() == aVersion) {
return true;
}
}
return false;
}
CatalogRef m_owner; CatalogRef m_owner;
std::string m_buffer; std::string m_buffer;
@@ -149,15 +112,22 @@ private:
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
CatalogList Catalog::allCatalogs()
{
return static_catalogs;
}
Catalog::Catalog(Root *aRoot) : Catalog::Catalog(Root *aRoot) :
m_root(aRoot), m_root(aRoot),
m_status(Delegate::FAIL_UNKNOWN),
m_retrievedTime(0) m_retrievedTime(0)
{ {
static_catalogs.push_back(this);
} }
Catalog::~Catalog() Catalog::~Catalog()
{ {
CatalogList::iterator it = std::find(static_catalogs.begin(), static_catalogs.end(), this);
static_catalogs.erase(it);
} }
CatalogRef Catalog::createFromUrl(Root* aRoot, const std::string& aUrl) CatalogRef Catalog::createFromUrl(Root* aRoot, const std::string& aUrl)
@@ -186,57 +156,20 @@ CatalogRef Catalog::createFromPath(Root* aRoot, const SGPath& aPath)
return NULL; return NULL;
} }
if (!checkVersion(aRoot->catalogVersion(), props)) { if (props->getStringValue("version") != aRoot->catalogVersion()) {
std::string redirect = redirectUrlForVersion(aRoot->catalogVersion(), props);
if (!redirect.empty()) {
SG_LOG(SG_GENERAL, SG_WARN, "catalog at " << aPath << ", version mismatch:\n\t"
<< "redirecting to alternate URL:" << redirect);
CatalogRef c = Catalog::createFromUrl(aRoot, redirect);
c->m_installRoot = aPath;
return c;
} else {
SG_LOG(SG_GENERAL, SG_WARN, "skipping catalog at " << aPath << ", version mismatch:\n\t" SG_LOG(SG_GENERAL, SG_WARN, "skipping catalog at " << aPath << ", version mismatch:\n\t"
<< props->getStringValue("version") << " vs required " << aRoot->catalogVersion()); << props->getStringValue("version") << " vs required " << aRoot->catalogVersion());
return NULL; return NULL;
} }
}
CatalogRef c = new Catalog(aRoot); CatalogRef c = new Catalog(aRoot);
c->m_installRoot = aPath; c->m_installRoot = aPath;
c->parseProps(props); // will set status c->parseProps(props);
c->parseTimestamp(); c->parseTimestamp();
return c; return c;
} }
bool Catalog::uninstall()
{
bool ok;
bool atLeastOneFailure = false;
BOOST_FOREACH(PackageRef p, installedPackages()) {
ok = p->existingInstall()->uninstall();
if (!ok) {
SG_LOG(SG_GENERAL, SG_WARN, "uninstall of package " <<
p->id() << " failed");
// continue trying other packages, bailing out here
// gains us nothing
atLeastOneFailure = true;
}
}
Dir d(m_installRoot);
ok = d.remove(true /* recursive */);
if (!ok) {
atLeastOneFailure = true;
}
changeStatus(atLeastOneFailure ? Delegate::FAIL_FILESYSTEM
: Delegate::FAIL_SUCCESS);
return ok;
}
PackageList const& PackageList const&
Catalog::packages() const Catalog::packages() const
{ {
@@ -303,7 +236,6 @@ InstallRef Catalog::installForPackage(PackageRef pkg) const
void Catalog::refresh() void Catalog::refresh()
{ {
Downloader* dl = new Downloader(this, url()); Downloader* dl = new Downloader(this, url());
// will iupdate status to IN_PROGRESS
m_root->makeHTTPRequest(dl); m_root->makeHTTPRequest(dl);
m_root->catalogRefreshBegin(this); m_root->catalogRefreshBegin(this);
} }
@@ -372,9 +304,6 @@ void Catalog::parseProps(const SGPropertyNode* aProps)
Dir d(m_installRoot); Dir d(m_installRoot);
d.create(0755); d.create(0755);
} }
// parsed XML ok, mark status as valid
changeStatus(Delegate::FAIL_SUCCESS);
} }
PackageRef Catalog::getPackageById(const std::string& aId) const PackageRef Catalog::getPackageById(const std::string& aId) const
@@ -453,7 +382,6 @@ std::string Catalog::getLocalisedString(const SGPropertyNode* aRoot, const char*
void Catalog::refreshComplete(Delegate::FailureCode aReason) void Catalog::refreshComplete(Delegate::FailureCode aReason)
{ {
m_root->catalogRefreshComplete(this, aReason); m_root->catalogRefreshComplete(this, aReason);
changeStatus(aReason);
} }
void Catalog::registerInstall(Install* ins) void Catalog::registerInstall(Install* ins)
@@ -474,26 +402,6 @@ void Catalog::unregisterInstall(Install* ins)
m_installed.erase(ins->package()); m_installed.erase(ins->package());
} }
void Catalog::changeStatus(Delegate::FailureCode newStatus)
{
if (m_status == newStatus) {
return;
}
m_status = newStatus;
m_statusCallbacks(this);
}
void Catalog::addStatusCallback(const Callback& cb)
{
m_statusCallbacks.push_back(cb);
}
Delegate::FailureCode Catalog::status() const
{
return m_status;
}
} // of namespace pkg } // of namespace pkg
} // of namespace simgear } // of namespace simgear
+2 -25
View File
@@ -22,14 +22,11 @@
#include <ctime> #include <ctime>
#include <map> #include <map>
#include <boost/bind.hpp>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx> #include <simgear/props/props.hxx>
#include <simgear/structure/SGReferenced.hxx> #include <simgear/structure/SGReferenced.hxx>
#include <simgear/structure/SGSharedPtr.hxx> #include <simgear/structure/SGSharedPtr.hxx>
#include <simgear/structure/function_list.hxx>
#include <simgear/package/Delegate.hxx> #include <simgear/package/Delegate.hxx>
@@ -63,14 +60,11 @@ public:
static CatalogRef createFromPath(Root* aRoot, const SGPath& aPath); static CatalogRef createFromPath(Root* aRoot, const SGPath& aPath);
static CatalogList allCatalogs();
Root* root() const Root* root() const
{ return m_root;}; { return m_root;};
/**
* uninstall this catalog entirely, including all installed packages
*/
bool uninstall();
/** /**
* perform a refresh of the catalog contents * perform a refresh of the catalog contents
*/ */
@@ -123,18 +117,6 @@ public:
* access the raw property data in the catalog * access the raw property data in the catalog
*/ */
SGPropertyNode* properties() const; SGPropertyNode* properties() const;
Delegate::FailureCode status() const;
typedef boost::function<void(Catalog*)> Callback;
void addStatusCallback(const Callback& cb);
template<class C>
void addStatusCallback(C* instance, void (C::*mem_func)(Catalog*))
{
return addStatusCallback(boost::bind(mem_func, instance, _1));
}
private: private:
Catalog(Root* aRoot); Catalog(Root* aRoot);
@@ -154,13 +136,10 @@ private:
std::string getLocalisedString(const SGPropertyNode* aRoot, const char* aName) const; std::string getLocalisedString(const SGPropertyNode* aRoot, const char* aName) const;
void changeStatus(Delegate::FailureCode newStatus);
Root* m_root; Root* m_root;
SGPropertyNode_ptr m_props; SGPropertyNode_ptr m_props;
SGPath m_installRoot; SGPath m_installRoot;
std::string m_url; std::string m_url;
Delegate::FailureCode m_status;
PackageList m_packages; PackageList m_packages;
time_t m_retrievedTime; time_t m_retrievedTime;
@@ -172,8 +151,6 @@ private:
// since it is only cleaned up in the Install destructor // since it is only cleaned up in the Install destructor
typedef std::map<PackageRef, Install*> PackageInstallDict; typedef std::map<PackageRef, Install*> PackageInstallDict;
PackageInstallDict m_installed; PackageInstallDict m_installed;
function_list<Callback> m_statusCallbacks;
}; };
} // of namespace pkg } // of namespace pkg
-107
View File
@@ -1,107 +0,0 @@
// Copyright (C) 2015 James Turner - zakalawe@mac.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#ifdef HAVE_CONFIG_H
# include <simgear_config.h>
#endif
#include <simgear/misc/test_macros.hxx>
#include <cstdlib>
#include <iostream>
#include <simgear/package/Catalog.hxx>
#include <simgear/package/Root.hxx>
#include <simgear/package/Package.hxx>
#include <simgear/misc/sg_dir.hxx>
using namespace simgear;
int parseTest()
{
SGPath rootPath = simgear::Dir::current().path();
rootPath.append("testRoot");
pkg::Root* root = new pkg::Root(rootPath, "8.1.12");
pkg::CatalogRef cat = pkg::Catalog::createFromPath(root, SGPath(SRC_DIR "/catalogTest1"));
VERIFY(cat.valid());
COMPARE(cat->id(), "org.flightgear.test.catalog1");
COMPARE(cat->url(), "http://download.flightgear.org/catalog1/catalog.xml");
COMPARE(cat->description(), "First test catalog");
// check the packages too
COMPARE(cat->packages().size(), 3);
pkg::PackageRef p1 = cat->packages().front();
COMPARE(p1->catalog(), cat.ptr());
COMPARE(p1->id(), "alpha");
COMPARE(p1->qualifiedId(), "org.flightgear.test.catalog1.alpha");
COMPARE(p1->name(), "Alpha package");
COMPARE(p1->revision(), 8);
COMPARE(p1->fileSizeBytes(), 1234567);
pkg::PackageRef p2 = cat->getPackageById("c172p");
VERIFY(p2.valid());
COMPARE(p2->qualifiedId(), "org.flightgear.test.catalog1.c172p");
COMPARE(p2->description(), "A plane made by Cessna");
// test filtering / searching too
string_set tags(p2->tags());
COMPARE(tags.size(), 4);
VERIFY(tags.find("ifr") != tags.end());
VERIFY(tags.find("cessna") != tags.end());
VERIFY(tags.find("jet") == tags.end());
SGPropertyNode_ptr queryA(new SGPropertyNode);
queryA->setStringValue("tag", "ifr");
VERIFY(p2->matches(queryA.ptr()));
SGPropertyNode_ptr queryB(new SGPropertyNode);
queryB->setStringValue("name", "ces");
VERIFY(p2->matches(queryB.ptr()));
SGPropertyNode_ptr queryC(new SGPropertyNode);
queryC->setStringValue("name", "foo");
VERIFY(!p2->matches(queryC.ptr()));
SGPropertyNode_ptr queryD(new SGPropertyNode);
queryD->setIntValue("rating-FDM", 3);
VERIFY(p2->matches(queryD.ptr()));
SGPropertyNode_ptr queryE(new SGPropertyNode);
queryE->setIntValue("rating-model", 5);
queryE->setStringValue("description", "cessna");
VERIFY(p2->matches(queryE.ptr()));
delete root;
return EXIT_SUCCESS;
}
int main(int argc, char* argv[])
{
parseTest();
std::cout << "Successfully passed all tests!" << std::endl;
return EXIT_SUCCESS;
}
+1 -2
View File
@@ -42,8 +42,7 @@ public:
FAIL_DOWNLOAD, ///< network issue FAIL_DOWNLOAD, ///< network issue
FAIL_EXTRACT, ///< package archive failed to extract cleanly FAIL_EXTRACT, ///< package archive failed to extract cleanly
FAIL_FILESYSTEM, ///< unknown filesystem error occurred FAIL_FILESYSTEM, ///< unknown filesystem error occurred
FAIL_VERSION, ///< version check mismatch FAIL_VERSION ///< version check mismatch
CATALOG_REFRESHED
} FailureCode; } FailureCode;
+2 -12
View File
@@ -313,21 +313,11 @@ void Install::startUpdate()
m_package->catalog()->root()->startInstall(this); m_package->catalog()->root()->startInstall(this);
} }
bool Install::uninstall() void Install::uninstall()
{ {
Dir d(m_path); Dir d(m_path);
if (!d.remove(true)) { d.remove(true);
SG_LOG(SG_GENERAL, SG_ALERT, "package uninstall failed: couldn't remove path " << m_path);
return false;
}
m_package->catalog()->unregisterInstall(this); m_package->catalog()->unregisterInstall(this);
return true;
}
bool Install::isDownloading() const
{
return (m_download != NULL);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
+1 -3
View File
@@ -74,9 +74,7 @@ public:
void startUpdate(); void startUpdate();
bool uninstall(); void uninstall();
bool isDownloading() const;
/** /**
* Set the handler to be called when the installation successfully * Set the handler to be called when the installation successfully
+1 -6
View File
@@ -187,11 +187,6 @@ std::string Package::description() const
return getLocalisedProp("description"); return getLocalisedProp("description");
} }
string_set Package::tags() const
{
return m_tags;
}
SGPropertyNode* Package::properties() const SGPropertyNode* Package::properties() const
{ {
return m_props.ptr(); return m_props.ptr();
@@ -243,7 +238,7 @@ PackageList Package::dependencies() const
// prefer local hangar package if possible, in case someone does something // prefer local hangar package if possible, in case someone does something
// silly with naming. Of course flightgear's aircraft search doesn't know // silly with naming. Of course flightgear's aircraft search doesn't know
// about hangars, so names still need to be unique. // about hanagrs, so names still need to be unique.
PackageRef depPkg = m_catalog->getPackageById(depName); PackageRef depPkg = m_catalog->getPackageById(depName);
if (!depPkg) { if (!depPkg) {
Root* rt = m_catalog->root(); Root* rt = m_catalog->root();
-2
View File
@@ -113,8 +113,6 @@ public:
bool matches(const SGPropertyNode* aFilter) const; bool matches(const SGPropertyNode* aFilter) const;
string_set tags() const;
/** /**
* download URLs for the package * download URLs for the package
*/ */
-22
View File
@@ -336,28 +336,6 @@ void Root::catalogRefreshComplete(CatalogRef aCat, Delegate::FailureCode aReason
} }
} }
bool Root::removeCatalogById(const std::string& aId)
{
CatalogDict::iterator catIt = d->catalogs.find(aId);
if (catIt == d->catalogs.end()) {
SG_LOG(SG_GENERAL, SG_WARN, "removeCatalogById: unknown ID:" << aId);
return false;
}
CatalogRef cat = catIt->second;
// drop the reference
d->catalogs.erase(catIt);
bool ok = cat->uninstall();
if (!ok) {
SG_LOG(SG_GENERAL, SG_WARN, "removeCatalogById: catalog :" << aId
<< "failed to uninstall");
}
return ok;
}
} // of namespace pkg } // of namespace pkg
} // of namespace simgear } // of namespace simgear
-6
View File
@@ -109,12 +109,6 @@ public:
CatalogRef getCatalogById(const std::string& aId) const; CatalogRef getCatalogById(const std::string& aId) const;
void scheduleToUpdate(InstallRef aInstall); void scheduleToUpdate(InstallRef aInstall);
/**
* remove a catalog. Will uninstall all packages originating
* from the catalog too.
*/
bool removeCatalogById(const std::string& aId);
private: private:
friend class Install; friend class Install;
friend class Catalog; friend class Catalog;
-64
View File
@@ -1,64 +0,0 @@
<?xml version="1.0"?>
<PropertyList>
<id>org.flightgear.test.catalog1</id>
<description>First test catalog</description>
<url>http://download.flightgear.org/catalog1/catalog.xml</url>
<version>8.1.*</version>
<version>8.0.0</version>
<version>8.2.0</version>
<package>
<id>alpha</id>
<name>Alpha package</name>
<revision type="int">8</revision>
<file-size-bytes type="int">1234567</file-size-bytes>
</package>
<package>
<id>c172p</id>
<name>Cessna 172-P</name>
<description>A plane made by Cessna</description>
<revision type="int">42</revision>
<file-size-bytes type="int">34567</file-size-bytes>
<tag>cessna</tag>
<tag>ga</tag>
<tag>piston</tag>
<tag>ifr</tag>
<rating>
<FDM type="int">3</FDM>
<systems type="int">4</systems>
<model type="int">5</model>
<cockpit type="int">4</cockpit>
</rating>
<!-- local dependency -->
<depends>
<id>org.flightgear.test.catalog1.common-sounds</id>
<revision>10</revision>
</depends>
<variant>
<id>c172p-2d-panel</id>
<name>C172 with 2d panel only</name>
</variant>
<variant>
<id>c172p-floats</id>
<name>C172 with floats</name>
</variant>
<variant>
<id>c172p-skis</id>
<name>C172 with skis</name>
</variant>
</package>
<package>
<id>common-sounds</id>
<name>Common sound files for test catalog aircraft</name>
<revision>10</revision>
</package>
</PropertyList>
+1 -2
View File
@@ -158,8 +158,7 @@ SG_MD5Transform(u_int32_t state[4], const u_int8_t block[MD5_BLOCK_LENGTH])
{ {
u_int32_t a, b, c, d, in[MD5_BLOCK_LENGTH / 4]; u_int32_t a, b, c, d, in[MD5_BLOCK_LENGTH / 4];
#if ((defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__) || \ #ifndef WORDS_BIGENDIAN
defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM) )
memcpy(in, block, sizeof(in)); memcpy(in, block, sizeof(in));
#else #else
for (a = 0; a < MD5_BLOCK_LENGTH / 4; a++) { for (a = 0; a < MD5_BLOCK_LENGTH / 4; a++) {
+1 -1
View File
@@ -122,7 +122,7 @@ int main(int argc, char** argv)
root->setDelegate(&dlg); root->setDelegate(&dlg);
cout << "Package root is:" << Dir::current().path() << endl; cout << "Package root is:" << Dir::current().path() << endl;
cout << "have " << root->catalogs().size() << " catalog(s)" << endl; cout << "have " << pkg::Catalog::allCatalogs().size() << " catalog(s)" << endl;
root->setHTTPClient(http); root->setHTTPClient(http);
+4 -4
View File
@@ -144,9 +144,9 @@ public:
#undef SG_DEF_ASSIGN_OP #undef SG_DEF_ASSIGN_OP
SGPropertyNode* node(bool aCreate = false) const SGPropertyNode* node() const
{ {
return PropertyObjectBase::node(aCreate); return PropertyObjectBase::node(false);
} }
}; // of template PropertyObject }; // of template PropertyObject
@@ -237,9 +237,9 @@ public:
return (s == value); return (s == value);
} }
SGPropertyNode* node(bool aCreate = false) const SGPropertyNode* node() const
{ {
return PropertyObjectBase::node(aCreate); return PropertyObjectBase::node(false);
} }
private: private:
}; };
-10
View File
@@ -326,15 +326,9 @@ public:
= GL2Extensions::Get(static_cast<unsigned>(contextId), true); = GL2Extensions::Get(static_cast<unsigned>(contextId), true);
if (!extensions) if (!extensions)
return; return;
#if OSG_VERSION_LESS_THAN(3,3,4)
if (!extensions->isGlslSupported()) if (!extensions->isGlslSupported())
return; return;
value = extensions->getLanguageVersion(); value = extensions->getLanguageVersion();
#else
if (!extensions->isGlslSupported)
return;
value = extensions->glslLanguageVersion;
#endif
} }
}; };
@@ -363,11 +357,7 @@ public:
= GL2Extensions::Get(static_cast<unsigned>(contextId), true); = GL2Extensions::Get(static_cast<unsigned>(contextId), true);
if (!extensions) if (!extensions)
return; return;
#if OSG_VERSION_LESS_THAN(3,3,4)
value = extensions->isGlslSupported(); value = extensions->isGlslSupported();
#else
value = extensions->isGlslSupported;
#endif
} }
}; };
-1
View File
@@ -323,7 +323,6 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
// Random vegetation properties // Random vegetation properties
wood_coverage = props->getDoubleValue("wood-coverage", 0.0); wood_coverage = props->getDoubleValue("wood-coverage", 0.0);
tree_effect = props->getStringValue("tree-effect", "Effects/tree");
tree_height = props->getDoubleValue("tree-height-m", 0.0); tree_height = props->getDoubleValue("tree-height-m", 0.0);
tree_width = props->getDoubleValue("tree-width-m", 0.0); tree_width = props->getDoubleValue("tree-width-m", 0.0);
tree_range = props->getDoubleValue("tree-range-m", 0.0); tree_range = props->getDoubleValue("tree-range-m", 0.0);
-11
View File
@@ -274,14 +274,6 @@ public:
*/ */
inline std::string get_tree_texture () const { return tree_texture; } inline std::string get_tree_texture () const { return tree_texture; }
/**
* Get the effect file name to use for trees
*
* @return the effect to use for this set of trees.
*/
inline std::string get_tree_effect () const { return tree_effect; }
/** /**
* Get the cosine of the maximum tree density slope angle. We * Get the cosine of the maximum tree density slope angle. We
* use the cosine as it can be compared directly to the z component * use the cosine as it can be compared directly to the z component
@@ -485,9 +477,6 @@ private:
// Tree texture, typically a strip of applicable tree textures // Tree texture, typically a strip of applicable tree textures
std::string tree_texture; std::string tree_texture;
// Tree effect to be used for a particular material
std::string tree_effect;
// Object mask, a simple RGB texture used as a mask when placing // Object mask, a simple RGB texture used as a mask when placing
// random vegetation, objects and buildings // random vegetation, objects and buildings
std::vector<Texture2DRef> _masks; std::vector<Texture2DRef> _masks;
@@ -128,11 +128,7 @@ void CloudShaderGeometry::drawImplementation(RenderInfo& renderInfo) const
sortData.frameSorted = frameNumber; sortData.frameSorted = frameNumber;
} }
#if OSG_VERSION_LESS_THAN(3,3,4)
const Extensions* extensions = getExtensions(state.getContextID(),true); const Extensions* extensions = getExtensions(state.getContextID(),true);
#else
const GLExtensions* extensions = GLExtensions::Get(state.getContextID(), true);
#endif
GLfloat ua1[3] = { (GLfloat) alpha_factor, GLfloat ua1[3] = { (GLfloat) alpha_factor,
(GLfloat) shade_factor, (GLfloat) shade_factor,
(GLfloat) cloud_height }; (GLfloat) cloud_height };
+5 -5
View File
@@ -386,10 +386,10 @@ BuildingBoundingBoxCallback::computeBound(const Drawable& drawable) const
int row = ((int) (mt_rand(&seed) * 1000)) % 5; int row = ((int) (mt_rand(&seed) * 1000)) % 5;
float base_y = (float) row * 16.0 * 3.0 / 1024.0; float base_y = (float) row * 16.0 * 3.0 / 1024.0;
float top_y = base_y + 16.0 * (float) building.floors / 1024.0; float top_y = base_y + 16.0 * (float) building.floors / 1024.0;
float left_x = 32.0 / 1024.0 * SGMisc<double>::round((float)building.width / 6.0f); float left_x = 32.0 / 1024.0 * round((float) building.width / 6.0f);
float right_x = 0.0f; float right_x = 0.0f;
float front_x = 384.0/1024.0; float front_x = 384.0/1024.0;
float back_x = 384.0 / 1024.0 + 32.0 / 1024.0 * SGMisc<double>::round((float)building.depth / 6.0f); float back_x = 384.0/1024.0 + 32.0 / 1024.0 * round((float) building.depth/ 6.0f);
// BASEMENT - uses the baseline texture // BASEMENT - uses the baseline texture
for (unsigned int i = 0; i < 16; i++) { for (unsigned int i = 0; i < 16; i++) {
@@ -424,7 +424,7 @@ BuildingBoundingBoxCallback::computeBound(const Drawable& drawable) const
if (building.pitched) { if (building.pitched) {
// Use the entire height of the roof texture // Use the entire height of the roof texture
top_y = base_y + 16.0 * 3.0 / 1024.0; top_y = base_y + 16.0 * 3.0 / 1024.0;
left_x = 512 / 1024.0 + 32.0 / 1024.0 * SGMisc<double>::round(building.width / 6.0f); left_x = 512/1024.0 + 32.0 / 1024.0 * round(building.width / 6.0f);
right_x = 512/1024.0; right_x = 512/1024.0;
front_x = 480.0/1024.0; front_x = 480.0/1024.0;
back_x = 512.0/1024.0; back_x = 512.0/1024.0;
@@ -475,7 +475,7 @@ BuildingBoundingBoxCallback::computeBound(const Drawable& drawable) const
int column = ((int) (mt_rand(&seed) * 1000)) % 5; int column = ((int) (mt_rand(&seed) * 1000)) % 5;
float base_y = 288 / 1024.0; float base_y = 288 / 1024.0;
float top_y = base_y + 16.0 * (float) building.floors / 1024.0; float top_y = base_y + 16.0 * (float) building.floors / 1024.0;
float left_x = column * 192.0 / 1024.0 + 32.0 / 1024.0 * SGMisc<double>::round((float)building.width / 10.0f); float left_x = column * 192.0 /1024.0 + 32.0 / 1024.0 * round((float) building.width / 10.0f);
float right_x = column * 192.0 /1024.0; float right_x = column * 192.0 /1024.0;
// BASEMENT - uses the baseline texture // BASEMENT - uses the baseline texture
@@ -560,7 +560,7 @@ BuildingBoundingBoxCallback::computeBound(const Drawable& drawable) const
int column = ((int) (mt_rand(&seed) * 1000)) % 8; int column = ((int) (mt_rand(&seed) * 1000)) % 8;
float base_y = 576 / 1024.0; float base_y = 576 / 1024.0;
float top_y = base_y + 16.0 * (float) building.floors / 1024.0; float top_y = base_y + 16.0 * (float) building.floors / 1024.0;
float left_x = column * 128.0 / 1024.0 + 32.0 / 1024.0 * SGMisc<double>::round((float)building.width / 20.0f); float left_x = column * 128.0 /1024.0 + 32.0 / 1024.0 * round((float) building.width / 20.0f);
float right_x = column * 128.0 /1024.0; float right_x = column * 128.0 /1024.0;
// BASEMENT - uses the baseline texture // BASEMENT - uses the baseline texture
+1 -4
View File
@@ -291,8 +291,7 @@ public:
float vegetation_density, float vegetation_density,
float cos_max_density_angle, float cos_max_density_angle,
float cos_zero_density_angle, float cos_zero_density_angle,
std::vector<SGVec3f>& points, std::vector<SGVec3f>& points)
std::vector<SGVec3f>& normals)
{ {
if ( !geometries.empty() ) { if ( !geometries.empty() ) {
const osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(geometries[0]->getVertexArray()); const osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(geometries[0]->getVertexArray());
@@ -367,11 +366,9 @@ public:
if (mt_rand(&seed) < img->getColor(x, y).g()) { if (mt_rand(&seed) < img->getColor(x, y).g()) {
// The red channel contains the rotation for this object // The red channel contains the rotation for this object
points.push_back(randomPoint); points.push_back(randomPoint);
normals.push_back(normalize(normal));
} }
} else { } else {
points.push_back(randomPoint); points.push_back(randomPoint);
normals.push_back(normalize(normal));
} }
} }
} }
+5 -9
View File
@@ -28,7 +28,6 @@
#include <osg/Geometry> #include <osg/Geometry>
#include <osg/PrimitiveSet> #include <osg/PrimitiveSet>
#include <osg/Texture2D> #include <osg/Texture2D>
#include <osg/ref_ptr>
#include <stdio.h> #include <stdio.h>
#include <simgear/math/sg_random.h> #include <simgear/math/sg_random.h>
@@ -123,16 +122,16 @@ public:
osg::DrawElements* getDrawElements() osg::DrawElements* getDrawElements()
{ {
if (count > 65535) { if (count > 65535) {
_ushortElements = 0; free (_ushortElements);
return _uintElements; return _uintElements;
} else { } else {
_uintElements = 0; free (_uintElements);
return _ushortElements; return _ushortElements;
} }
} }
protected: protected:
osg::ref_ptr<osg::DrawElementsUShort> _ushortElements; osg::DrawElementsUShort* _ushortElements;
osg::ref_ptr<osg::DrawElementsUInt> _uintElements; osg::DrawElementsUInt* _uintElements;
unsigned count; unsigned count;
}; };
@@ -216,8 +215,7 @@ public:
float vegetation_density, float vegetation_density,
float cos_max_density_angle, float cos_max_density_angle,
float cos_zero_density_angle, float cos_zero_density_angle,
std::vector<SGVec3f>& points, std::vector<SGVec3f>& points)
std::vector<SGVec3f>& normals)
{ {
unsigned num = getNumTriangles(); unsigned num = getNumTriangles();
for (unsigned i = 0; i < num; ++i) { for (unsigned i = 0; i < num; ++i) {
@@ -283,11 +281,9 @@ public:
if (mt_rand(&seed) < img->getColor(x, y).g()) { if (mt_rand(&seed) < img->getColor(x, y).g()) {
// The red channel contains the rotation for this object // The red channel contains the rotation for this object
points.push_back(randomPoint); points.push_back(randomPoint);
normals.push_back(normalize(normal));
} }
} else { } else {
points.push_back(randomPoint); points.push_back(randomPoint);
normals.push_back(normalize(normal));
} }
} }
} }
+4 -10
View File
@@ -723,7 +723,6 @@ public:
BOOST_FOREACH(bin, randomForest) BOOST_FOREACH(bin, randomForest)
{ {
if ((bin->texture == mat->get_tree_texture() ) && if ((bin->texture == mat->get_tree_texture() ) &&
(bin->teffect == mat->get_tree_effect() ) &&
(bin->texture_varieties == mat->get_tree_varieties()) && (bin->texture_varieties == mat->get_tree_varieties()) &&
(bin->range == mat->get_tree_range() ) && (bin->range == mat->get_tree_range() ) &&
(bin->width == mat->get_tree_width() ) && (bin->width == mat->get_tree_width() ) &&
@@ -737,8 +736,6 @@ public:
bin = new TreeBin(); bin = new TreeBin();
bin->texture = mat->get_tree_texture(); bin->texture = mat->get_tree_texture();
SG_LOG(SG_INPUT, SG_DEBUG, "Tree texture " << bin->texture); SG_LOG(SG_INPUT, SG_DEBUG, "Tree texture " << bin->texture);
bin->teffect = mat->get_tree_effect();
SG_LOG(SG_INPUT, SG_DEBUG, "Tree effect " << bin->teffect);
bin->range = mat->get_tree_range(); bin->range = mat->get_tree_range();
bin->width = mat->get_tree_width(); bin->width = mat->get_tree_width();
bin->height = mat->get_tree_height(); bin->height = mat->get_tree_height();
@@ -747,19 +744,16 @@ public:
} }
std::vector<SGVec3f> randomPoints; std::vector<SGVec3f> randomPoints;
std::vector<SGVec3f> randomPointNormals;
matTris[i].addRandomTreePoints(wood_coverage, matTris[i].addRandomTreePoints(wood_coverage,
mat->get_one_object_mask(matTris[i].getTextureIndex()), mat->get_one_object_mask(matTris[i].getTextureIndex()),
vegetation_density, vegetation_density,
mat->get_cos_tree_max_density_slope_angle(), mat->get_cos_tree_max_density_slope_angle(),
mat->get_cos_tree_zero_density_slope_angle(), mat->get_cos_tree_zero_density_slope_angle(),
randomPoints, randomPoints);
randomPointNormals);
std::vector<SGVec3f>::iterator k; std::vector<SGVec3f>::iterator k;
std::vector<SGVec3f>::iterator j; for (k = randomPoints.begin(); k != randomPoints.end(); ++k) {
for (k = randomPoints.begin(), j = randomPointNormals.begin(); k != randomPoints.end(); ++k, ++j) { bin->insert(*k);
bin->insert(*k, *j);
} }
} }
} }
@@ -877,7 +871,7 @@ public:
lightGroup->addChild(groundLights2); lightGroup->addChild(groundLights2);
} }
if (! vasiLights.empty()) { if (vasiLights.empty()) {
EffectGeode* vasiGeode = new EffectGeode; EffectGeode* vasiGeode = new EffectGeode;
Effect* vasiEffect = getLightEffect(24, osg::Vec3(1, 0.0001, 0.000001), 1, 24, true, _options); Effect* vasiEffect = getLightEffect(24, osg::Vec3(1, 0.0001, 0.000001), 1, 24, true, _options);
vasiGeode->setEffect(vasiEffect); vasiGeode->setEffect(vasiEffect);
-4
View File
@@ -47,11 +47,7 @@ void ShaderGeometry::addObject(const Vec3& position, float scale,
void ShaderGeometry::drawImplementation(osg::RenderInfo& renderInfo) const void ShaderGeometry::drawImplementation(osg::RenderInfo& renderInfo) const
{ {
State& state = *renderInfo.getState(); State& state = *renderInfo.getState();
#if OSG_VERSION_LESS_THAN(3,3,4)
const Extensions* extensions = getExtensions(state.getContextID(), true); const Extensions* extensions = getExtensions(state.getContextID(), true);
#else
const GLExtensions* extensions = GLExtensions::Get(state.getContextID(), true);
#endif
Vec4Array::const_iterator citer = _posScaleArray->begin(); Vec4Array::const_iterator citer = _posScaleArray->begin();
Vec4Array::const_iterator cend = _posScaleArray->end(); Vec4Array::const_iterator cend = _posScaleArray->end();
FloatArray::const_iterator viter = _vertexAttribArray->begin(); FloatArray::const_iterator viter = _vertexAttribArray->begin();
+7 -45
View File
@@ -49,7 +49,6 @@
#include <simgear/scene/util/QuadTreeBuilder.hxx> #include <simgear/scene/util/QuadTreeBuilder.hxx>
#include <simgear/scene/util/RenderConstants.hxx> #include <simgear/scene/util/RenderConstants.hxx>
#include <simgear/scene/util/StateAttributeFactory.hxx> #include <simgear/scene/util/StateAttributeFactory.hxx>
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <simgear/structure/OSGUtils.hxx> #include <simgear/structure/OSGUtils.hxx>
#include "ShaderGeometry.hxx" #include "ShaderGeometry.hxx"
@@ -63,9 +62,6 @@ using namespace osg;
namespace simgear namespace simgear
{ {
bool use_tree_shadows;
bool use_tree_normals;
// Tree instance scheme: // Tree instance scheme:
// vertex - local position of quad vertex. // vertex - local position of quad vertex.
// normal - x y scaling, z number of varieties // normal - x y scaling, z number of varieties
@@ -168,24 +164,15 @@ Geometry* createTreeGeometry(float width, float height, int varieties)
// Positions // Positions
quadGeom->setColorArray(new Vec3Array); quadGeom->setColorArray(new Vec3Array);
quadGeom->setColorBinding(Geometry::BIND_PER_VERTEX); quadGeom->setColorBinding(Geometry::BIND_PER_VERTEX);
// Normals FloatArray* rotation = new FloatArray(2);
if (use_tree_shadows || use_tree_normals)
{
quadGeom->setSecondaryColorArray(new Vec3Array);
quadGeom->setSecondaryColorBinding(Geometry::BIND_PER_VERTEX);
}
FloatArray* rotation = new FloatArray(3);
(*rotation)[0] = 0.0; (*rotation)[0] = 0.0;
(*rotation)[1] = PI_2; (*rotation)[1] = PI_2;
if (use_tree_shadows) {(*rotation)[2] = -1.0;}
quadGeom->setFogCoordArray(rotation); quadGeom->setFogCoordArray(rotation);
quadGeom->setFogCoordBinding(Geometry::BIND_PER_PRIMITIVE_SET); quadGeom->setFogCoordBinding(Geometry::BIND_PER_PRIMITIVE_SET);
// The primitive sets render the same geometry, but the second // The primitive sets render the same geometry, but the second
// will rotated 90 degrees by the vertex shader, which uses the // will rotated 90 degrees by the vertex shader, which uses the
// fog coordinate as a rotation. // fog coordinate as a rotation.
int imax = 2; for (int i = 0; i < 2; ++i)
if (use_tree_shadows) {imax = 3;}
for (int i = 0; i < imax; ++i)
quadGeom->addPrimitiveSet(new DrawArrays(PrimitiveSet::QUADS)); quadGeom->addPrimitiveSet(new DrawArrays(PrimitiveSet::QUADS));
return quadGeom; return quadGeom;
} }
@@ -197,17 +184,13 @@ EffectGeode* createTreeGeode(float width, float height, int varieties)
return result; return result;
} }
void addTreeToLeafGeode(Geode* geode, const SGVec3f& p, const SGVec3f& t) void addTreeToLeafGeode(Geode* geode, const SGVec3f& p)
{ {
Vec3 pos = toOsg(p); Vec3 pos = toOsg(p);
Vec3 ter = toOsg(t);
unsigned int numDrawables = geode->getNumDrawables(); unsigned int numDrawables = geode->getNumDrawables();
Geometry* geom Geometry* geom
= static_cast<Geometry*>(geode->getDrawable(numDrawables - 1)); = static_cast<Geometry*>(geode->getDrawable(numDrawables - 1));
Vec3Array* posArray = static_cast<Vec3Array*>(geom->getColorArray()); Vec3Array* posArray = static_cast<Vec3Array*>(geom->getColorArray());
Vec3Array* tnormalArray;
if (use_tree_shadows || use_tree_normals)
{tnormalArray = static_cast<Vec3Array*>(geom->getSecondaryColorArray());}
if (posArray->size() if (posArray->size()
>= static_cast<Vec3Array*>(geom->getVertexArray())->size()) { >= static_cast<Vec3Array*>(geom->getVertexArray())->size()) {
Vec3Array* paramsArray Vec3Array* paramsArray
@@ -215,17 +198,11 @@ void addTreeToLeafGeode(Geode* geode, const SGVec3f& p, const SGVec3f& t)
Vec3 params = (*paramsArray)[0]; Vec3 params = (*paramsArray)[0];
geom = createTreeGeometry(params.x(), params.y(), params.z()); geom = createTreeGeometry(params.x(), params.y(), params.z());
posArray = static_cast<Vec3Array*>(geom->getColorArray()); posArray = static_cast<Vec3Array*>(geom->getColorArray());
if (use_tree_shadows || use_tree_normals)
{tnormalArray = static_cast<Vec3Array*>(geom->getSecondaryColorArray());}
geode->addDrawable(geom); geode->addDrawable(geom);
} }
posArray->insert(posArray->end(), 4, pos); posArray->insert(posArray->end(), 4, pos);
if (use_tree_shadows || use_tree_normals)
{tnormalArray->insert(tnormalArray->end(),4,ter);}
size_t numVerts = posArray->size(); size_t numVerts = posArray->size();
int imax = 2; for (int i = 0; i < 2; ++i) {
if (use_tree_shadows) {imax = 3;}
for (int i = 0; i < imax; ++i) {
DrawArrays* primSet DrawArrays* primSet
= static_cast<DrawArrays*>(geom->getPrimitiveSet(i)); = static_cast<DrawArrays*>(geom->getPrimitiveSet(i));
primSet->setCount(numVerts); primSet->setCount(numVerts);
@@ -278,7 +255,7 @@ struct AddTreesLeafObject
void operator() (LOD* lod, const TreeBin::Tree& tree) const void operator() (LOD* lod, const TreeBin::Tree& tree) const
{ {
Geode* geode = static_cast<Geode*>(lod->getChild(int(tree.position.x() * 10.0f) % lod->getNumChildren())); Geode* geode = static_cast<Geode*>(lod->getChild(int(tree.position.x() * 10.0f) % lod->getNumChildren()));
addTreeToLeafGeode(geode, tree.position, tree.tnormal); addTreeToLeafGeode(geode, tree.position);
} }
}; };
@@ -300,8 +277,7 @@ struct TreeTransformer
TreeBin::Tree operator()(const TreeBin::Tree& tree) const TreeBin::Tree operator()(const TreeBin::Tree& tree) const
{ {
Vec3 pos = toOsg(tree.position); Vec3 pos = toOsg(tree.position);
Vec3 norm = toOsg(tree.tnormal); return TreeBin::Tree(toSG(pos * mat));
return TreeBin::Tree(toSG(pos * mat),toSG(norm * mat));
} }
Matrix mat; Matrix mat;
}; };
@@ -357,20 +333,6 @@ osg::Group* createForest(SGTreeBinList& forestList, const osg::Matrix& transform
SGTreeBinList::iterator i; SGTreeBinList::iterator i;
use_tree_shadows = false;
use_tree_normals = false;
if (options) {
SGPropertyNode* propertyNode = options->getPropertyNode().get();
if (propertyNode) {
use_tree_shadows
= propertyNode->getBoolValue("/sim/rendering/random-vegetation-shadows",
use_tree_shadows);
use_tree_normals
= propertyNode->getBoolValue("/sim/rendering/random-vegetation-normals",
use_tree_normals);
}
}
for (i = forestList.begin(); i != forestList.end(); ++i) { for (i = forestList.begin(); i != forestList.end(); ++i) {
TreeBin* forest = *i; TreeBin* forest = *i;
@@ -381,7 +343,7 @@ osg::Group* createForest(SGTreeBinList& forestList, const osg::Matrix& transform
(!iter->second.lock(effect))) (!iter->second.lock(effect)))
{ {
SGPropertyNode_ptr effectProp = new SGPropertyNode; SGPropertyNode_ptr effectProp = new SGPropertyNode;
makeChild(effectProp, "inherits-from")->setStringValue(forest->teffect); makeChild(effectProp, "inherits-from")->setStringValue("Effects/tree");
SGPropertyNode* params = makeChild(effectProp, "parameters"); SGPropertyNode* params = makeChild(effectProp, "parameters");
// emphasize n = 0 // emphasize n = 0
params->getChild("texture", 0, true)->getChild("image", 0, true) params->getChild("texture", 0, true)->getChild("image", 0, true)
+5 -7
View File
@@ -36,10 +36,10 @@ namespace simgear
class TreeBin { class TreeBin {
public: public:
struct Tree { struct Tree {
SGVec3f position; Tree(const SGVec3f& p) :
SGVec3f tnormal; position(p)
Tree(const SGVec3f& p, const SGVec3f& t) : position(p),tnormal(t)
{ } { }
SGVec3f position;
}; };
typedef std::vector<Tree> TreeList; typedef std::vector<Tree> TreeList;
@@ -49,13 +49,11 @@ public:
float height; float height;
float width; float width;
std::string texture; std::string texture;
std::string teffect;
void insert(const Tree& t) void insert(const Tree& t)
{ _trees.push_back(t); } { _trees.push_back(t); }
void insert(const SGVec3f& p, int t, float s)
void insert(const SGVec3f& p, const SGVec3f& tnorm) { insert(Tree(p)); }
{insert(Tree(p,tnorm));}
unsigned getNumTrees() const unsigned getNumTrees() const
{ return _trees.size(); } { return _trees.size(); }
+10 -68
View File
@@ -199,43 +199,6 @@ static unsigned int syncSlotForType(SyncItem::Type ty)
} }
} }
///////////////////////////////////////////////////////////////////////////////
// Base server query
///////////////////////////////////////////////////////////////////////////////
class ServerSelectQuery : public HTTP::Request
{
public:
ServerSelectQuery() :
HTTP::Request("http://scenery.flightgear.org/svn-server", "GET")
{
}
std::string svnUrl() const
{
std::string s = simgear::strutils::strip(m_url);
if (s.at(s.length() - 1) == '/') {
s = s.substr(0, s.length() - 1);
}
return s;
}
protected:
virtual void gotBodyData(const char* s, int n)
{
m_url.append(std::string(s, n));
}
virtual void onFail()
{
SG_LOG(SG_TERRAIN, SG_ALERT, "Failed to query TerraSync SVN server");
HTTP::Request::onFail();
}
private:
std::string m_url;
};
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// SGTerraSync::SvnThread ///////////////////////////////////////////////////// // SGTerraSync::SvnThread /////////////////////////////////////////////////////
@@ -400,7 +363,14 @@ bool SGTerraSync::SvnThread::start()
_use_svn |= _use_built_in; _use_svn |= _use_built_in;
if ((_use_svn)&&(_svn_server==""))
{
SG_LOG(SG_TERRAIN,SG_ALERT,
"Cannot start scenery download. Subversion scenery server is undefined.");
_fail_count++;
_stalled = true;
return false;
}
if ((!_use_svn)&&(_rsync_server=="")) if ((!_use_svn)&&(_rsync_server==""))
{ {
SG_LOG(SG_TERRAIN,SG_ALERT, SG_LOG(SG_TERRAIN,SG_ALERT,
@@ -503,32 +473,6 @@ void SGTerraSync::SvnThread::run()
_active = true; _active = true;
initCompletedTilesPersistentCache(); initCompletedTilesPersistentCache();
{
if (_svn_server.empty()) {
SG_LOG(SG_TERRAIN,SG_INFO, "Querying closest TerraSync server");
ServerSelectQuery* ssq = new ServerSelectQuery;
HTTP::Request_ptr req = ssq;
_http.makeRequest(req);
while (!req->isComplete()) {
_http.update(20);
}
if (req->readyState() == HTTP::Request::DONE) {
_svn_server = ssq->svnUrl();
SG_LOG(SG_TERRAIN,SG_INFO, "Closest TerraSync server:" << _svn_server);
} else {
SG_LOG(SG_TERRAIN,SG_WARN, "Failed to query closest TerraSync server");
}
} else {
SG_LOG(SG_TERRAIN,SG_INFO, "Explicit: TerraSync server:" << _svn_server);
}
if (_svn_server.empty()) {
// default value
_svn_server = "http://foxtrot.mgras.net:8080/terrascenery/trunk/data/Scenery";
}
}
if (_use_built_in) { if (_use_built_in) {
runInternal(); runInternal();
} else { } else {
@@ -604,7 +548,7 @@ void SGTerraSync::SvnThread::updateSyncSlot(SyncSlot &slot)
{ {
if (slot.repository.get()) { if (slot.repository.get()) {
if (slot.repository->isDoingSync()) { if (slot.repository->isDoingSync()) {
#if 1 #if 0
if (slot.stamp.elapsedMSec() > slot.nextWarnTimeout) { if (slot.stamp.elapsedMSec() > slot.nextWarnTimeout) {
SG_LOG(SG_TERRAIN, SG_INFO, "sync taking a long time:" << slot.currentItem._dir << " taken " << slot.stamp.elapsedMSec()); SG_LOG(SG_TERRAIN, SG_INFO, "sync taking a long time:" << slot.currentItem._dir << " taken " << slot.stamp.elapsedMSec());
SG_LOG(SG_TERRAIN, SG_INFO, "HTTP status:" << _http.hasActiveRequests()); SG_LOG(SG_TERRAIN, SG_INFO, "HTTP status:" << _http.hasActiveRequests());
@@ -661,7 +605,7 @@ void SGTerraSync::SvnThread::updateSyncSlot(SyncSlot &slot)
slot.nextWarnTimeout = 20000; slot.nextWarnTimeout = 20000;
slot.stamp.stamp(); slot.stamp.stamp();
slot.busy = true; slot.busy = true;
SG_LOG(SG_TERRAIN, SG_INFO, "sync of " << slot.repository->baseUrl() << " started, queue size is " << slot.queue.size()); SG_LOG(SG_TERRAIN, SG_DEBUG, "sync of " << slot.repository->baseUrl() << " started, queue size is " << slot.queue.size());
} }
} }
@@ -739,8 +683,6 @@ void SGTerraSync::SvnThread::fail(SyncItem failedItem)
_fail_count++; _fail_count++;
failedItem._status = SyncItem::Failed; failedItem._status = SyncItem::Failed;
_freshTiles.push_back(failedItem); _freshTiles.push_back(failedItem);
SG_LOG(SG_TERRAIN,SG_INFO,
"Faield to sync'" << failedItem._dir << "'");
_completedTiles[ failedItem._dir ] = now + UpdateInterval::FailedAttempt; _completedTiles[ failedItem._dir ] = now + UpdateInterval::FailedAttempt;
_is_dirty = true; _is_dirty = true;
} }
-22
View File
@@ -25,13 +25,11 @@
#include "SGSceneFeatures.hxx" #include "SGSceneFeatures.hxx"
#include <osg/Version>
#include <osg/FragmentProgram> #include <osg/FragmentProgram>
#include <osg/VertexProgram> #include <osg/VertexProgram>
#include <osg/Point> #include <osg/Point>
#include <osg/PointSprite> #include <osg/PointSprite>
#include <osg/Texture> #include <osg/Texture>
#include <osg/GLExtensions>
#include <OpenThreads/Mutex> #include <OpenThreads/Mutex>
#include <OpenThreads/ScopedLock> #include <OpenThreads/ScopedLock>
@@ -86,18 +84,12 @@ SGSceneFeatures::setTextureCompression(osg::Texture* texture) const
bool bool
SGSceneFeatures::getHavePointSprites(unsigned contextId) const SGSceneFeatures::getHavePointSprites(unsigned contextId) const
{ {
#if OSG_VERSION_LESS_THAN(3,3,4)
return osg::PointSprite::isPointSpriteSupported(contextId); return osg::PointSprite::isPointSpriteSupported(contextId);
#else
const osg::GLExtensions* ex = osg::GLExtensions::Get(contextId, true);
return ex && ex->isPointSpriteSupported;
#endif
} }
bool bool
SGSceneFeatures::getHaveFragmentPrograms(unsigned contextId) const SGSceneFeatures::getHaveFragmentPrograms(unsigned contextId) const
{ {
#if OSG_VERSION_LESS_THAN(3,3,4)
const osg::FragmentProgram::Extensions* fpe; const osg::FragmentProgram::Extensions* fpe;
fpe = osg::FragmentProgram::getExtensions(contextId, true); fpe = osg::FragmentProgram::getExtensions(contextId, true);
if (!fpe) if (!fpe)
@@ -106,16 +98,11 @@ SGSceneFeatures::getHaveFragmentPrograms(unsigned contextId) const
return false; return false;
return true; return true;
#else
const osg::GLExtensions* ex = osg::GLExtensions::Get(contextId, true);
return ex && ex->isFragmentProgramSupported;
#endif
} }
bool bool
SGSceneFeatures::getHaveVertexPrograms(unsigned contextId) const SGSceneFeatures::getHaveVertexPrograms(unsigned contextId) const
{ {
#if OSG_VERSION_LESS_THAN(3,3,4)
const osg::VertexProgram::Extensions* vpe; const osg::VertexProgram::Extensions* vpe;
vpe = osg::VertexProgram::getExtensions(contextId, true); vpe = osg::VertexProgram::getExtensions(contextId, true);
if (!vpe) if (!vpe)
@@ -124,10 +111,6 @@ SGSceneFeatures::getHaveVertexPrograms(unsigned contextId) const
return false; return false;
return true; return true;
#else
const osg::GLExtensions* ex = osg::GLExtensions::Get(contextId, true);
return ex && ex->isVertexProgramSupported;
#endif
} }
bool bool
@@ -141,7 +124,6 @@ SGSceneFeatures::getHaveShaderPrograms(unsigned contextId) const
bool bool
SGSceneFeatures::getHavePointParameters(unsigned contextId) const SGSceneFeatures::getHavePointParameters(unsigned contextId) const
{ {
#if OSG_VERSION_LESS_THAN(3,3,4)
const osg::Point::Extensions* pe; const osg::Point::Extensions* pe;
pe = osg::Point::getExtensions(contextId, true); pe = osg::Point::getExtensions(contextId, true);
if (!pe) if (!pe)
@@ -149,9 +131,5 @@ SGSceneFeatures::getHavePointParameters(unsigned contextId) const
if (!pe->isPointParametersSupported()) if (!pe->isPointParametersSupported())
return false; return false;
return true; return true;
#else
const osg::GLExtensions* ex = osg::GLExtensions::Get(contextId, true);
return ex && ex->isPointParametersSupported;
#endif
} }
+3 -6
View File
@@ -402,8 +402,7 @@ void SGSampleGroup::set_volume( float vol )
// set the source position and orientation of all managed sounds // set the source position and orientation of all managed sounds
void SGSampleGroup::update_pos_and_orientation() { void SGSampleGroup::update_pos_and_orientation() {
SGVec3d base_position = SGVec3d::fromGeod(_base_pos); SGVec3d position = SGVec3d::fromGeod(_base_pos) - _smgr->get_position();
SGVec3d smgr_position = _smgr->get_position();
SGQuatd hlOr = SGQuatd::fromLonLat(_base_pos); SGQuatd hlOr = SGQuatd::fromLonLat(_base_pos);
SGQuatd ec2body = hlOr*_orientation; SGQuatd ec2body = hlOr*_orientation;
@@ -419,14 +418,12 @@ void SGSampleGroup::update_pos_and_orientation() {
sample->set_master_volume( _volume ); sample->set_master_volume( _volume );
sample->set_orientation( _orientation ); sample->set_orientation( _orientation );
sample->set_rotation( ec2body ); sample->set_rotation( ec2body );
sample->set_position(base_position); sample->set_position( position );
sample->set_velocity( velocity ); sample->set_velocity( velocity );
// Test if a sample is farther away than max distance, if so // Test if a sample is farther away than max distance, if so
// stop the sound playback and free it's source. // stop the sound playback and free it's source.
if (!_tied_to_listener) { if (!_tied_to_listener) {
sample->update_pos_and_orientation();
SGVec3d position = sample->get_position() - smgr_position;
float max2 = sample->get_max_dist() * sample->get_max_dist(); float max2 = sample->get_max_dist() * sample->get_max_dist();
float dist2 = position[0]*position[0] float dist2 = position[0]*position[0]
+ position[1]*position[1] + position[2]*position[2]; + position[1]*position[1] + position[2]*position[2];
@@ -452,7 +449,7 @@ void SGSampleGroup::update_sample_config( SGSoundSample *sample )
} else { } else {
sample->update_pos_and_orientation(); sample->update_pos_and_orientation();
orientation = sample->get_orientation(); orientation = sample->get_orientation();
position = sample->get_position() - _smgr->get_position(); position = sample->get_position();
velocity = sample->get_velocity(); velocity = sample->get_velocity();
} }
+1 -1
View File
@@ -116,7 +116,7 @@ void SampleHistogram::reset ()
this->SampleStatistic::reset (); this->SampleStatistic::reset ();
if (howManyBuckets > 0) if (howManyBuckets > 0)
{ {
for (int i = 0; i < howManyBuckets; i++) for (register int i = 0; i < howManyBuckets; i++)
{ {
bucketCount[i] = 0; bucketCount[i] = 0;
} }
+4 -4
View File
@@ -439,9 +439,9 @@ void StateMachine::initFromPlist(SGPropertyNode* desc, SGPropertyNode* root)
std::string nm = stateDesc->getStringValue("name"); std::string nm = stateDesc->getStringValue("name");
State_ptr st(new State(nm)); State_ptr st(new State(nm));
readBindingList(stateDesc, "enter", root, st->d->_entryBindings); readBindingList(stateDesc, "enter", root, st->d->_updateBindings);
readBindingList(stateDesc, "update", root, st->d->_updateBindings); readBindingList(stateDesc, "exit", root, st->d->_entryBindings);
readBindingList(stateDesc, "exit", root, st->d->_exitBindings); readBindingList(stateDesc, "update", root, st->d->_exitBindings);
addState(st); addState(st);
} // of states iteration } // of states iteration
@@ -456,7 +456,7 @@ void StateMachine::initFromPlist(SGPropertyNode* desc, SGPropertyNode* root)
t->setTriggerCondition(cond); t->setTriggerCondition(cond);
t->setExcludeTarget(tDesc->getBoolValue("exclude-target", true)); t->setExcludeTarget(tDesc->getBoolValue("exclude-target", true));
BOOST_FOREACH(SGPropertyNode* src, tDesc->getChildren("source")) { BOOST_FOREACH(SGPropertyNode* src, desc->getChildren("source")) {
State_ptr srcState = findStateByName(src->getStringValue()); State_ptr srcState = findStateByName(src->getStringValue());
t->addSourceState(srcState); t->addSourceState(srcState);
} }
+1 -4
View File
@@ -58,11 +58,8 @@ void SGEventMgr::unbind()
void SGEventMgr::init() void SGEventMgr::init()
{ {
if (_inited) { if (_inited) {
// protected against duplicate calls here, in case SG_LOG(SG_GENERAL, SG_WARN, "duplicate init of SGEventMgr");
// init ever does something more complex in the future.
return;
} }
_inited = true; _inited = true;
} }
+9 -9
View File
@@ -267,7 +267,7 @@ void show(const char *zone, time_t t, int v)
static char *abbr(struct tm *tmp) static char *abbr(struct tm *tmp)
{ {
char * result; register char * result;
static char nada; static char nada;
if (tmp->tm_isdst != 0 && tmp->tm_isdst != 1) if (tmp->tm_isdst != 0 && tmp->tm_isdst != 1)
@@ -627,7 +627,7 @@ static int fgcompute_change (fgtz_rule *rule, int year)
// tz_rule *rule; // tz_rule *rule;
// int year; // int year;
{ {
time_t t; register time_t t;
int y; int y;
if (year != -1 && rule->computed_for == year) if (year != -1 && rule->computed_for == year)
@@ -660,8 +660,8 @@ static int fgcompute_change (fgtz_rule *rule, int year)
case fgtz_rule::M: case fgtz_rule::M:
/* Mm.n.d - Nth "Dth day" of month M. */ /* Mm.n.d - Nth "Dth day" of month M. */
{ {
int i, d, m1, yy0, yy1, yy2, dow; register int i, d, m1, yy0, yy1, yy2, dow;
const unsigned short int *myday = register const unsigned short int *myday =
&mon_yday[isleap (year)][rule->m]; &mon_yday[isleap (year)][rule->m];
/* First add SECSPERDAY for each day in months before M. */ /* First add SECSPERDAY for each day in months before M. */
@@ -707,7 +707,7 @@ static int fgcompute_change (fgtz_rule *rule, int year)
int fgtzfile_compute (time_t timer, int use_localtime, int fgtzfile_compute (time_t timer, int use_localtime,
long int *leap_correct, int *leap_hit) long int *leap_correct, int *leap_hit)
{ {
size_t i; register size_t i;
if (use_localtime) if (use_localtime)
{ {
@@ -788,10 +788,10 @@ void fgtzfile_read (const char *file)
{ {
// static const char default_tzdir[] = TZDIR; // static const char default_tzdir[] = TZDIR;
size_t num_isstd, num_isgmt; size_t num_isstd, num_isgmt;
FILE *f; register FILE *f;
struct tzhead tzhead; struct tzhead tzhead;
size_t chars; size_t chars;
size_t i; register size_t i;
struct ttinfo *info; struct ttinfo *info;
use_fgtzfile = 0; use_fgtzfile = 0;
@@ -1046,8 +1046,8 @@ void offtime (const time_t *t, long int offset, struct tm *tp)
// long int offset; // long int offset;
// struct tm *tp; // struct tm *tp;
{ {
long int days, rem, y; register long int days, rem, y;
const unsigned short int *ip; register const unsigned short int *ip;
days = *t / SECS_PER_DAY; days = *t / SECS_PER_DAY;
rem = *t % SECS_PER_DAY; rem = *t % SECS_PER_DAY;
+1 -1
View File
@@ -1 +1 @@
3.6.0 3.4.0