From: Tim Moore Date: Thu, 6 May 2010 08:43:53 +0000 (+0200) Subject: Merge branch 'jmt/ref_ptr-conv' X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2cc2a857a2cc2daff30601e0f8f697c768dd5b30;hp=9f9c4cf32c2cf774c7febd7fe2b4e65a7d205294;p=simgear.git Merge branch 'jmt/ref_ptr-conv' --- diff --git a/Makefile.am b/Makefile.am index aac4221e..f88767c3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,6 @@ EXTRA_DIST = \ acinclude.m4 \ autogen.sh \ DoxygenMain.cxx \ - README.MSVC \ README.zlib \ README.plib \ README.OpenAL \ diff --git a/README.MSVC b/README.MSVC deleted file mode 100644 index 33a89c2a..00000000 --- a/README.MSVC +++ /dev/null @@ -1,24 +0,0 @@ -This document describes how to build SimGear using the supplied workspace and -project files. - -Unpack the SimGear source file into your work directory. This creates a new -subdirectory called SimGear-X.Y.Z. Rename this to SimGear. Before we can -build SimGear you must unpack and build the third party libraries metakit and -zlib. Sources for these are included in the SimGear/src-libs directory. -Unpack these into the top level SimGear directory. At this point your -directory structure should look something like this: - -/ - SimGear/ - metakit-x.y.z/ - simgear/ - src-libs/ - zlib-x.y.z/ - -Now open the SimGear workspace. This workspace file contains projects for -building metakit(mklib), SimGear and zlib. Select each project as the active -project and build all. Order is unimportant since there are no dependencies -between the projects. - -The workspace and project files are generated by a perl script with extra -input from the am2dsp.cfg file. diff --git a/projects/VC7.1/.cvsignore b/projects/VC7.1/.cvsignore deleted file mode 100755 index 0f890e0a..00000000 --- a/projects/VC7.1/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -Debug -Release -SimGear.ncb -SimGear.suo -*.user diff --git a/projects/VC7.1/SimGear.sln b/projects/VC7.1/SimGear.sln deleted file mode 100755 index 9683d4d6..00000000 --- a/projects/VC7.1/SimGear.sln +++ /dev/null @@ -1,21 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimGear", "SimGear.vcproj", "{22540CD3-D3CA-4C86-A773-80AEEE3ACDED}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {22540CD3-D3CA-4C86-A773-80AEEE3ACDED}.Debug.ActiveCfg = Debug|Win32 - {22540CD3-D3CA-4C86-A773-80AEEE3ACDED}.Debug.Build.0 = Debug|Win32 - {22540CD3-D3CA-4C86-A773-80AEEE3ACDED}.Release.ActiveCfg = Release|Win32 - {22540CD3-D3CA-4C86-A773-80AEEE3ACDED}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/projects/VC7.1/SimGear.vcproj b/projects/VC7.1/SimGear.vcproj deleted file mode 100755 index 783ac4d0..00000000 --- a/projects/VC7.1/SimGear.vcproj +++ /dev/null @@ -1,1383 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/simgear/math/SGBox.hxx b/simgear/math/SGBox.hxx index 8024a131..dfa50275 100644 --- a/simgear/math/SGBox.hxx +++ b/simgear/math/SGBox.hxx @@ -71,6 +71,14 @@ public: (pt[2] > center[2]) ? _min[2] : _max[2]); } + // return the closest point to pt still in the box + template + SGVec3 getClosestPoint(const SGVec3& pt) const + { + return SGVec3((pt[0] < _min[0]) ? _min[0] : ((_max[0] < pt[0]) ? _max[0] : T(pt[0])), + (pt[1] < _min[1]) ? _min[1] : ((_max[1] < pt[1]) ? _max[1] : T(pt[1])), + (pt[2] < _min[2]) ? _min[2] : ((_max[2] < pt[2]) ? _max[2] : T(pt[2]))); + } // Only works for floating point types SGVec3 getCenter() const diff --git a/simgear/math/SGIntersect.hxx b/simgear/math/SGIntersect.hxx index 533bd2dc..24741f64 100644 --- a/simgear/math/SGIntersect.hxx +++ b/simgear/math/SGIntersect.hxx @@ -38,25 +38,11 @@ intersects(const SGBox& box, const SGSphere& sphere) { if (sphere.empty()) return false; - // Is more or less trivially included in the next tests - // if (box.empty()) - // return false; - - if (sphere.getCenter().x() < box.getMin().x() - sphere.getRadius()) - return false; - if (sphere.getCenter().y() < box.getMin().y() - sphere.getRadius()) - return false; - if (sphere.getCenter().z() < box.getMin().z() - sphere.getRadius()) + if (box.empty()) return false; - if (box.getMax().x() + sphere.getRadius() < sphere.getCenter().x()) - return false; - if (box.getMax().y() + sphere.getRadius() < sphere.getCenter().y()) - return false; - if (box.getMax().z() + sphere.getRadius() < sphere.getCenter().z()) - return false; - - return true; + SGVec3 closest = box.getClosestPoint(sphere.getCenter()); + return distSqr(closest, SGVec3(sphere.getCenter())) <= sphere.getRadius2(); } // make it symmetric template diff --git a/simgear/scene/material/matmodel.cxx b/simgear/scene/material/matmodel.cxx index bdad512e..93cbd494 100644 --- a/simgear/scene/material/matmodel.cxx +++ b/simgear/scene/material/matmodel.cxx @@ -135,14 +135,11 @@ SGMatModel::load_models( SGPropertyNode *prop_root ) } osg::Node* -SGMatModel::get_random_model( SGPropertyNode *prop_root ) +SGMatModel::get_random_model( SGPropertyNode *prop_root, mt seed ) { load_models( prop_root ); // comment this out if preloading models int nModels = _models.size(); - int index = int(sg_random() * nModels); - if (index >= nModels) - index = 0; - return _models[index].get(); + return _models[mt_rand(&seed) * nModels].get(); } double diff --git a/simgear/scene/material/matmodel.hxx b/simgear/scene/material/matmodel.hxx index 9d06427a..3e7d84a9 100644 --- a/simgear/scene/material/matmodel.hxx +++ b/simgear/scene/material/matmodel.hxx @@ -82,7 +82,7 @@ public: * * @return A randomly select model from the variants. */ - osg::Node *get_random_model( SGPropertyNode *prop_root ); + osg::Node *get_random_model( SGPropertyNode *prop_root, mt seed ); /** diff --git a/simgear/scene/tgdb/obj.cxx b/simgear/scene/tgdb/obj.cxx index dec3c6c4..fd6d42e2 100644 --- a/simgear/scene/tgdb/obj.cxx +++ b/simgear/scene/tgdb/obj.cxx @@ -611,7 +611,7 @@ SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool calc_lights, bool i < tileGeometryBin.randomModels.getNumModels(); i++) { SGMatModelBin::MatModel obj = tileGeometryBin.randomModels.getMatModel(i); - osg::Node* node = sgGetRandomModel(obj.model); + osg::Node* node = sgGetRandomModel(obj.model, seed); // Create a matrix to place the object in the correct // location, and then apply the rotation matrix created diff --git a/simgear/scene/tgdb/userdata.cxx b/simgear/scene/tgdb/userdata.cxx index 11d69e12..6aa71821 100644 --- a/simgear/scene/tgdb/userdata.cxx +++ b/simgear/scene/tgdb/userdata.cxx @@ -60,8 +60,8 @@ void sgUserDataInit( SGPropertyNode *p ) { root_props = p; } -osg::Node* sgGetRandomModel(SGMatModel *obj) { - return obj->get_random_model( root_props ); +osg::Node* sgGetRandomModel(SGMatModel *obj, mt seed) { + return obj->get_random_model( root_props, seed ); } namespace simgear diff --git a/simgear/scene/tgdb/userdata.hxx b/simgear/scene/tgdb/userdata.hxx index ab0a6a55..fa5209e6 100644 --- a/simgear/scene/tgdb/userdata.hxx +++ b/simgear/scene/tgdb/userdata.hxx @@ -26,6 +26,7 @@ #define _SG_USERDATA_HXX #include +#include #include @@ -42,7 +43,7 @@ void sgUserDataInit(SGPropertyNode *p); /** * Get a random model. */ -osg::Node* sgGetRandomModel(SGMatModel *obj); +osg::Node* sgGetRandomModel(SGMatModel *obj, mt seed); namespace simgear { diff --git a/simgear/screen/extensions.hxx b/simgear/screen/extensions.hxx index d7999bc6..e1871068 100644 --- a/simgear/screen/extensions.hxx +++ b/simgear/screen/extensions.hxx @@ -202,7 +202,7 @@ typedef void (APIENTRY * glClientActiveTextureProc)(GLenum texture); #define GL_RGB_SCALE_ARB 0x8573 #define GL_ADD_SIGNED_ARB 0x8574 #define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 +#define GL_SUBTRACT_ARB 0x84E7 #define GL_CONSTANT_ARB 0x8576 #define GL_PRIMARY_COLOR_ARB 0x8577 #define GL_PREVIOUS_ARB 0x8578 @@ -766,6 +766,62 @@ typedef void (APIENTRY * glGetVertexAttribivProc) (GLuint index, GLenum pname, G typedef void (APIENTRY * glGetVertexAttribPointervProc) (GLuint index, GLenum pname, GLvoid* *pointer); typedef GLboolean (APIENTRY * glIsProgramProc) (GLuint program); +/* + * EXT_framebuffer_objects + */ +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#define GL_NONE_EXT 0 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGB565_EXT 0x8D62 +#define GL_DEPTH_COMPONENT16_EXT 0x81A5 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#endif + +typedef GLboolean (APIENTRY * glIsRenderbufferProc) (GLuint renderbuffer); +typedef void (APIENTRY * glBindRenderbufferProc) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRY * glDeleteRenderbuffersProc) (GLsizei n, const GLuint* renderbuffers); +typedef void (APIENTRY * glGenRenderbuffersProc) (GLsizei n, GLuint* renderbuffers); +typedef void (APIENTRY * glRenderbufferStorageProc) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRY * glGetRenderbufferParameterivProc) (GLenum target, GLenum pname, GLint* params); +typedef GLboolean (APIENTRY * glIsFramebufferProc) (GLuint framebuffer); +typedef void (APIENTRY * glBindFramebufferProc) (GLenum target, GLuint framebuffer); +typedef void (APIENTRY * glDeleteFramebuffersProc) (GLsizei n, const GLuint* framebuffers); +typedef void (APIENTRY * glGenFramebuffersProc) (GLsizei n, GLuint* framebuffers); +typedef GLenum (APIENTRY * glCheckFramebufferStatusProc) (GLenum target); +typedef void (APIENTRY * glFramebufferRenderbufferProc) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRY * glFramebufferTexture2DProc) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRY * glGetFramebufferAttachmentParameterivProc) (GLenum target, GLenum attachment, GLenum pname, GLint* params); +typedef void (APIENTRY * glGenerateMipmapProc) (GLenum target); + /* * ARB_shader_objects */ diff --git a/simgear/sound/soundmgr_openal.cxx b/simgear/sound/soundmgr_openal.cxx index e372f3cc..16d9e794 100644 --- a/simgear/sound/soundmgr_openal.cxx +++ b/simgear/sound/soundmgr_openal.cxx @@ -30,7 +30,7 @@ #endif #if defined( __APPLE__ ) -# include +# include #else # include #endif @@ -45,10 +45,17 @@ #include #include +using std::string; + extern bool isNaN(float *v); #define MAX_SOURCES 128 + +#ifndef ALC_ALL_DEVICES_SPECIFIER +# define ALC_ALL_DEVICES_SPECIFIER 0x1013 +#endif + // // Sound Manager // @@ -81,6 +88,8 @@ SGSoundMgr::SGSoundMgr() : } } _alut_init++; +#else + #error ALUT 1.1 required, ALUT 1.0 is no longer supported, please upgrade #endif } diff --git a/simgear/sound/soundmgr_openal.hxx b/simgear/sound/soundmgr_openal.hxx index 9b9e0a12..749d8427 100644 --- a/simgear/sound/soundmgr_openal.hxx +++ b/simgear/sound/soundmgr_openal.hxx @@ -35,32 +35,19 @@ #ifndef _SG_SOUNDMGR_OPENAL_HXX #define _SG_SOUNDMGR_OPENAL_HXX 1 -#ifndef __cplusplus -# error This library requires C++ -#endif - #include #include #include #if defined(__APPLE__) -# define AL_ILLEGAL_ENUM AL_INVALID_ENUM -# define AL_ILLEGAL_COMMAND AL_INVALID_OPERATION # include # include -# include #elif defined(OPENALSDK) # include # include -# include #else # include # include -# include -#endif - -#ifndef ALC_ALL_DEVICES_SPECIFIER -# define ALC_ALL_DEVICES_SPECIFIER 0x1013 #endif #include @@ -68,9 +55,6 @@ #include #include "sample_group.hxx" -#include "sample_openal.hxx" - -using std::string; struct refUint { unsigned int refctr; @@ -81,11 +65,11 @@ struct refUint { ~refUint() {}; }; -typedef std::map < string, refUint > buffer_map; +typedef std::map < std::string, refUint > buffer_map; typedef buffer_map::iterator buffer_map_iterator; typedef buffer_map::const_iterator const_buffer_map_iterator; -typedef std::map < string, SGSharedPtr > sample_group_map; +typedef std::map < std::string, SGSharedPtr > sample_group_map; typedef sample_group_map::iterator sample_group_map_iterator; typedef sample_group_map::const_iterator const_sample_group_map_iterator; @@ -133,21 +117,21 @@ public: * @param refname Reference name of the sample group * @return true if successful, false otherwise */ - bool add( SGSampleGroup *sgrp, const string& refname ); + bool add( SGSampleGroup *sgrp, const std::string& refname ); /** * Remove a sample group from the sound manager. * @param refname Reference name of the sample group to remove * @return true if successful, false otherwise */ - bool remove( const string& refname ); + bool remove( const std::string& refname ); /** * Test if a specified sample group is registered at the sound manager * @param refname Reference name of the sample group test for * @return true if the specified sample group exists */ - bool exists( const string& refname ); + bool exists( const std::string& refname ); /** * Find a specified sample group in the sound manager @@ -287,13 +271,13 @@ public: /** * Get a list of available playback devices. */ - vector get_available_devices(); + std::vector get_available_devices(); /** * Get the current OpenAL vendor or rendering backend. */ - const string& get_vendor() { return _vendor; } - const string& get_renderer() { return _renderer; } + const std::string& get_vendor() { return _vendor; } + const std::string& get_renderer() { return _renderer; } private: static int _alut_init; @@ -323,17 +307,17 @@ private: sample_group_map _sample_groups; buffer_map _buffers; - vector _free_sources; - vector _sources_in_use; + std::vector _free_sources; + std::vector _sources_in_use; bool _bad_doppler; - string _renderer; - string _vendor; + std::string _renderer; + std::string _vendor; - bool testForALError(string s); - bool testForALCError(string s); - bool testForALUTError(string s); - bool testForError(void *p, string s); + bool testForALError(std::string s); + bool testForALCError(std::string s); + bool testForALUTError(std::string s); + bool testForError(void *p, std::string s); void update_pos_and_orientation(); void update_sample_config( SGSampleGroup *sound );