1
0
Fork 0

Merge branch 'next' of D:\Git_New\flightgear into next

This commit is contained in:
Vivian Meazza 2010-11-18 23:51:12 +00:00
commit 12d10066a6
10 changed files with 408 additions and 118 deletions

View file

@ -106,6 +106,9 @@ it in a scheduled task. To do that :
64bit environment (Vista 64-bit or Windows7 64-bit) 64bit environment (Vista 64-bit or Windows7 64-bit)
You should see : "Setting environment for using Microsoft Visual Studio 2008 x86 tools." You should see : "Setting environment for using Microsoft Visual Studio 2008 x86 tools."
printed in the console printed in the console
( To start 64-bit build, the right environment is set with :
"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" amd64
)
3. cd to the FlightGear project directory : 3. cd to the FlightGear project directory :
D: D:
cd \FGFSDevel\FlightGear\projects\VC90 (for example) cd \FGFSDevel\FlightGear\projects\VC90 (for example)

View file

@ -40,7 +40,7 @@ end
prefixDir=Dir.pwd + "/dist" prefixDir=Dir.pwd + "/dist"
dmgDir=Dir.pwd + "/image" dmgDir=Dir.pwd + "/image"
srcDir=Dir.pwd + "/flightgear" srcDir=Dir.pwd + "/flightgear"
dmgPath = Dir.pwd + "/fg_mac_nightly.dmg"
puts "Erasing previous image dir" puts "Erasing previous image dir"
`rm -rf #{dmgDir}` `rm -rf #{dmgDir}`
@ -55,6 +55,8 @@ volName="\"FlightGear Nightly Build\""
VERSION = File.read("#{srcDir}/version").strip VERSION = File.read("#{srcDir}/version").strip
dmgPath = Dir.pwd + "/fg_mac_nightly_#{VERSION}.dmg"
puts "Creating directory structure" puts "Creating directory structure"
`mkdir -p #{macosDir}` `mkdir -p #{macosDir}`
`mkdir -p #{frameworksDir}` `mkdir -p #{frameworksDir}`

25
scripts/tools/version.bat Normal file
View file

@ -0,0 +1,25 @@
REM
ECHO OFF
SET /P FLIGHTGEAR_VERSION=<version
SET HUDSON_BUILD_NUMBER=0
SET HUDSON_BUILD_ID=none
SET REVISION=none
IF DEFINED BUILD_ID SET HUDSON_BUILD_ID=%BUILD_ID%
IF DEFINED BUILD_NUMBER SET HUDSON_BUILD_NUMBER=%BUILD_NUMBER%
SET Header=src\Include\version.h
ECHO // version.h generated by version.bat on %DATE% > %Header%
ECHO #define FLIGHTGEAR_VERSION "%FLIGHTGEAR_VERSION%" >> %Header%
ECHO #define HUDSON_BUILD_ID "%HUDSON_BUILD_ID%" >> %Header%
ECHO #define HUDSON_BUILD_NUMBER %HUDSON_BUILD_NUMBER% >> %Header%
ECHO #define REVISION "%REVISION%" >> %Header%

View file

@ -49,6 +49,7 @@ extern void guiErrorMessage(const char *txt, const sg_throwable &throwable);
extern bool fgDumpSnapShot(); extern bool fgDumpSnapShot();
extern void fgDumpSceneGraph(); extern void fgDumpSceneGraph();
extern void fgDumpTerrainBranch(); extern void fgDumpTerrainBranch();
extern void fgPrintVisibleSceneInfoCommand();
extern puFont guiFnt; extern puFont guiFnt;
extern fntTexFont *guiFntHandle; extern fntTexFont *guiFntHandle;

View file

@ -555,5 +555,22 @@ void fgDumpTerrainBranch()
} }
} }
void fgPrintVisibleSceneInfoCommand()
{
static const SGPropertyNode *master_freeze
= fgGetNode("/sim/freeze/master");
bool freeze = master_freeze->getBoolValue();
if ( !freeze ) {
fgSetBool("/sim/freeze/master", true);
}
flightgear::printVisibleSceneInfo(globals->get_renderer());
if ( !freeze ) {
fgSetBool("/sim/freeze/master", false);
}
}

View file

@ -518,6 +518,13 @@ do_dump_terrain_branch (const SGPropertyNode*)
return true; return true;
} }
static bool
do_print_visible_scene_info(const SGPropertyNode*)
{
fgPrintVisibleSceneInfoCommand();
return true;
}
/** /**
* Built-in command: hires capture screen. * Built-in command: hires capture screen.
*/ */
@ -1488,6 +1495,7 @@ static struct {
{ "release-cockpit-button", do_release_cockpit_button }, { "release-cockpit-button", do_release_cockpit_button },
{ "dump-scenegraph", do_dump_scene_graph }, { "dump-scenegraph", do_dump_scene_graph },
{ "dump-terrainbranch", do_dump_terrain_branch }, { "dump-terrainbranch", do_dump_terrain_branch },
{ "print-visible-scene", do_print_visible_scene_info },
{ "reload-shaders", do_reload_shaders }, { "reload-shaders", do_reload_shaders },
{ 0, 0 } // zero-terminated { 0, 0 } // zero-terminated
}; };

View file

@ -56,7 +56,9 @@
#include "util.hxx" #include "util.hxx"
#include "viewmgr.hxx" #include "viewmgr.hxx"
#include <Main/viewer.hxx> #include <Main/viewer.hxx>
#include <simgear/version.h> #include <simgear/version.h>
#include <osg/Version>
using std::string; using std::string;
using std::sort; using std::sort;
@ -237,7 +239,8 @@ fgSetDefaults ()
fgSetInt("/sim/multiplay/txport", 0); fgSetInt("/sim/multiplay/txport", 0);
fgSetString("/sim/version/flightgear", FLIGHTGEAR_VERSION); fgSetString("/sim/version/flightgear", FLIGHTGEAR_VERSION);
//fgSetString("/sim/version/simgear", FLIGHTGEAR_VERSION); fgSetString("/sim/version/simgear", SG_STRINGIZE(SIMGEAR_VERSION));
fgSetString("/sim/version/openscenegraph", osgGetVersion());
fgSetString("/sim/version/revision", REVISION); fgSetString("/sim/version/revision", REVISION);
fgSetInt("/sim/version/build-number", HUDSON_BUILD_NUMBER); fgSetInt("/sim/version/build-number", HUDSON_BUILD_NUMBER);
fgSetString("/sim/version/build-id", HUDSON_BUILD_ID); fgSetString("/sim/version/build-id", HUDSON_BUILD_ID);

View file

@ -29,11 +29,18 @@
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <typeinfo>
#include <osg/ref_ptr> #include <osg/ref_ptr>
#include <osg/AlphaFunc> #include <osg/AlphaFunc>
#include <osg/BlendFunc> #include <osg/BlendFunc>
#include <osg/Camera> #include <osg/Camera>
#include <osg/CullFace> #include <osg/CullFace>
#include <osg/CullStack>
#include <osg/Depth> #include <osg/Depth>
#include <osg/Fog> #include <osg/Fog>
#include <osg/Group> #include <osg/Group>
@ -823,5 +830,207 @@ fgDumpNodeToFile(osg::Node* node, const char* filename)
{ {
return osgDB::writeNodeFile(*node, filename); return osgDB::writeNodeFile(*node, filename);
} }
namespace flightgear
{
using namespace osg;
class VisibleSceneInfoVistor : public NodeVisitor, CullStack
{
public:
VisibleSceneInfoVistor()
: NodeVisitor(CULL_VISITOR, TRAVERSE_ACTIVE_CHILDREN)
{
setCullingMode(CullSettings::SMALL_FEATURE_CULLING
| CullSettings::VIEW_FRUSTUM_CULLING);
setComputeNearFarMode(CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
}
VisibleSceneInfoVistor(const VisibleSceneInfoVistor& rhs)
{
}
META_NodeVisitor("flightgear","VisibleSceneInfoVistor")
typedef std::map<const std::string,int> InfoMap;
void getNodeInfo(Node* node)
{
const char* typeName = typeid(*node).name();
classInfo[typeName]++;
const std::string& nodeName = node->getName();
if (!nodeName.empty())
nodeInfo[nodeName]++;
}
void dumpInfo()
{
using namespace std;
typedef vector<InfoMap::iterator> FreqVector;
cout << "class info:\n";
FreqVector classes;
for (InfoMap::iterator itr = classInfo.begin(), end = classInfo.end();
itr != end;
++itr)
classes.push_back(itr);
sort(classes.begin(), classes.end(), freqComp);
for (FreqVector::iterator itr = classes.begin(), end = classes.end();
itr != end;
++itr) {
cout << (*itr)->first << " " << (*itr)->second << "\n";
}
cout << "\nnode info:\n";
FreqVector nodes;
for (InfoMap::iterator itr = nodeInfo.begin(), end = nodeInfo.end();
itr != end;
++itr)
nodes.push_back(itr);
sort (nodes.begin(), nodes.end(), freqComp);
for (FreqVector::iterator itr = nodes.begin(), end = nodes.end();
itr != end;
++itr) {
cout << (*itr)->first << " " << (*itr)->second << "\n";
}
cout << endl;
}
void doTraversal(Camera* camera, Node* root, Viewport* viewport)
{
ref_ptr<RefMatrix> projection
= createOrReuseMatrix(camera->getProjectionMatrix());
ref_ptr<RefMatrix> mv = createOrReuseMatrix(camera->getViewMatrix());
if (!viewport)
viewport = camera->getViewport();
if (viewport)
pushViewport(viewport);
pushProjectionMatrix(projection.get());
pushModelViewMatrix(mv.get(), Transform::ABSOLUTE_RF);
root->accept(*this);
popModelViewMatrix();
popProjectionMatrix();
if (viewport)
popViewport();
dumpInfo();
}
void apply(Node& node)
{
if (isCulled(node))
return;
pushCurrentMask();
getNodeInfo(&node);
traverse(node);
popCurrentMask();
}
void apply(Group& node)
{
if (isCulled(node))
return;
pushCurrentMask();
getNodeInfo(&node);
traverse(node);
popCurrentMask();
}
void apply(Transform& node)
{
if (isCulled(node))
return;
pushCurrentMask();
ref_ptr<RefMatrix> matrix = createOrReuseMatrix(*getModelViewMatrix());
node.computeLocalToWorldMatrix(*matrix,this);
pushModelViewMatrix(matrix.get(), node.getReferenceFrame());
getNodeInfo(&node);
traverse(node);
popModelViewMatrix();
popCurrentMask();
}
void apply(Camera& camera)
{
// Save current cull settings
CullSettings saved_cull_settings(*this);
// set cull settings from this Camera
setCullSettings(camera);
// inherit the settings from above
inheritCullSettings(saved_cull_settings, camera.getInheritanceMask());
// set the cull mask.
unsigned int savedTraversalMask = getTraversalMask();
bool mustSetCullMask = (camera.getInheritanceMask()
& osg::CullSettings::CULL_MASK) == 0;
if (mustSetCullMask)
setTraversalMask(camera.getCullMask());
osg::RefMatrix* projection = 0;
osg::RefMatrix* modelview = 0;
if (camera.getReferenceFrame()==osg::Transform::RELATIVE_RF) {
if (camera.getTransformOrder()==osg::Camera::POST_MULTIPLY) {
projection = createOrReuseMatrix(*getProjectionMatrix()
*camera.getProjectionMatrix());
modelview = createOrReuseMatrix(*getModelViewMatrix()
* camera.getViewMatrix());
}
else { // pre multiply
projection = createOrReuseMatrix(camera.getProjectionMatrix()
* (*getProjectionMatrix()));
modelview = createOrReuseMatrix(camera.getViewMatrix()
* (*getModelViewMatrix()));
}
} else {
// an absolute reference frame
projection = createOrReuseMatrix(camera.getProjectionMatrix());
modelview = createOrReuseMatrix(camera.getViewMatrix());
}
if (camera.getViewport())
pushViewport(camera.getViewport());
pushProjectionMatrix(projection);
pushModelViewMatrix(modelview, camera.getReferenceFrame());
traverse(camera);
// restore the previous model view matrix.
popModelViewMatrix();
// restore the previous model view matrix.
popProjectionMatrix();
if (camera.getViewport()) popViewport();
// restore the previous traversal mask settings
if (mustSetCullMask)
setTraversalMask(savedTraversalMask);
// restore the previous cull settings
setCullSettings(saved_cull_settings);
}
protected:
// sort in reverse
static bool freqComp(const InfoMap::iterator& lhs, const InfoMap::iterator& rhs)
{
return lhs->second > rhs->second;
}
InfoMap classInfo;
InfoMap nodeInfo;
};
bool printVisibleSceneInfo(FGRenderer* renderer)
{
osgViewer::Viewer* viewer = renderer->getViewer();
VisibleSceneInfoVistor vsv;
Viewport* vp = 0;
if (!viewer->getCamera()->getViewport() && viewer->getNumSlaves() > 0) {
const View::Slave& slave = viewer->getSlave(0);
vp = slave._camera->getViewport();
}
vsv.doTraversal(viewer->getCamera(), viewer->getSceneData(), vp);
return true;
}
}
// end of renderer.cxx // end of renderer.cxx

View file

@ -81,4 +81,9 @@ protected:
bool fgDumpSceneGraphToFile(const char* filename); bool fgDumpSceneGraphToFile(const char* filename);
bool fgDumpTerrainBranchToFile(const char* filename); bool fgDumpTerrainBranchToFile(const char* filename);
namespace flightgear
{
bool printVisibleSceneInfo(FGRenderer* renderer);
}
#endif #endif

View file

@ -536,127 +536,144 @@ FGMultiplayMgr::SendMyPosition(const FGExternalMotionData& motionInfo)
return; return;
} }
MsgBuf msgBuf; static MsgBuf msgBuf;
static unsigned msgLen = 0;
T_PositionMsg* PosMsg = msgBuf.posMsg(); T_PositionMsg* PosMsg = msgBuf.posMsg();
strncpy(PosMsg->Model, fgGetString("/sim/model/path"), MAX_MODEL_NAME_LEN); strncpy(PosMsg->Model, fgGetString("/sim/model/path"), MAX_MODEL_NAME_LEN);
PosMsg->Model[MAX_MODEL_NAME_LEN - 1] = '\0'; PosMsg->Model[MAX_MODEL_NAME_LEN - 1] = '\0';
if (fgGetBool("/sim/freeze/replay-state", true))
PosMsg->time = XDR_encode_double (motionInfo.time); {
PosMsg->lag = XDR_encode_double (motionInfo.lag); // do not send position updates during replay
for (unsigned i = 0 ; i < 3; ++i) for (unsigned i = 0 ; i < 3; ++i)
PosMsg->position[i] = XDR_encode_double (motionInfo.position(i)); {
SGVec3f angleAxis; // no movement during replay
motionInfo.orientation.getAngleAxis(angleAxis); PosMsg->linearVel[i] = XDR_encode_float (0.0);
for (unsigned i = 0 ; i < 3; ++i) PosMsg->angularVel[i] = XDR_encode_float (0.0);
PosMsg->orientation[i] = XDR_encode_float (angleAxis(i)); PosMsg->linearAccel[i] = XDR_encode_float (0.0);
for (unsigned i = 0 ; i < 3; ++i) PosMsg->angularAccel[i] = XDR_encode_float (0.0);
PosMsg->linearVel[i] = XDR_encode_float (motionInfo.linearVel(i)); }
for (unsigned i = 0 ; i < 3; ++i) // all other data remains unchanged (resend last state)
PosMsg->angularVel[i] = XDR_encode_float (motionInfo.angularVel(i));
for (unsigned i = 0 ; i < 3; ++i)
PosMsg->linearAccel[i] = XDR_encode_float (motionInfo.linearAccel(i));
for (unsigned i = 0 ; i < 3; ++i)
PosMsg->angularAccel[i] = XDR_encode_float (motionInfo.angularAccel(i));
xdr_data_t* ptr = msgBuf.properties();
std::vector<FGPropertyData*>::const_iterator it;
it = motionInfo.properties.begin();
//cout << "OUTPUT PROPERTIES\n";
xdr_data_t* msgEnd = msgBuf.propsEnd();
while (it != motionInfo.properties.end() && ptr + 2 < msgEnd) {
// First element is the ID. Write it out when we know we have room for
// the whole property.
xdr_data_t id = XDR_encode_uint32((*it)->id);
// The actual data representation depends on the type
switch ((*it)->type) {
case simgear::props::INT:
case simgear::props::BOOL:
case simgear::props::LONG:
*ptr++ = id;
*ptr++ = XDR_encode_uint32((*it)->int_value);
//cout << "Prop:" << (*it)->id << " " << (*it)->type << " "<< (*it)->int_value << "\n";
break;
case simgear::props::FLOAT:
case simgear::props::DOUBLE:
*ptr++ = id;
*ptr++ = XDR_encode_float((*it)->float_value);
//cout << "Prop:" << (*it)->id << " " << (*it)->type << " "<< (*it)->float_value << "\n";
break;
case simgear::props::STRING:
case simgear::props::UNSPECIFIED:
{
// String is complicated. It consists of
// The length of the string
// The string itself
// Padding to the nearest 4-bytes.
const char* lcharptr = (*it)->string_value;
if (lcharptr != 0)
{
// Add the length
////cout << "String length: " << strlen(lcharptr) << "\n";
uint32_t len = strlen(lcharptr);
if (len > MAX_TEXT_SIZE)
len = MAX_TEXT_SIZE;
// XXX This should not be using 4 bytes per character!
// If there's not enough room for this property, drop it
// on the floor.
if (ptr + 2 + ((len + 3) & ~3) > msgEnd)
goto escape;
//cout << "String length unint32: " << len << "\n";
*ptr++ = id;
*ptr++ = XDR_encode_uint32(len);
if (len != 0)
{
// Now the text itself
// XXX This should not be using 4 bytes per character!
int lcount = 0;
while ((*lcharptr != '\0') && (lcount < MAX_TEXT_SIZE))
{
*ptr++ = XDR_encode_int8(*lcharptr);
lcharptr++;
lcount++;
}
//cout << "Prop:" << (*it)->id << " " << (*it)->type << " " << len << " " << (*it)->string_value;
// Now pad if required
while ((lcount % 4) != 0)
{
*ptr++ = XDR_encode_int8(0);
lcount++;
//cout << "0";
}
//cout << "\n";
}
}
else
{
// Nothing to encode
*ptr++ = id;
*ptr++ = XDR_encode_uint32(0);
//cout << "Prop:" << (*it)->id << " " << (*it)->type << " 0\n";
}
}
break;
default:
//cout << " Unknown Type: " << (*it)->type << "\n";
*ptr++ = id;
*ptr++ = XDR_encode_float((*it)->float_value);;
//cout << "Prop:" << (*it)->id << " " << (*it)->type << " "<< (*it)->float_value << "\n";
break;
}
++it;
} }
escape: else
unsigned msgLen = reinterpret_cast<char*>(ptr) - msgBuf.Msg; {
FillMsgHdr(msgBuf.msgHdr(), POS_DATA_ID, msgLen); PosMsg->time = XDR_encode_double (motionInfo.time);
mSocket->sendto(msgBuf.Msg, msgLen, 0, &mServer); PosMsg->lag = XDR_encode_double (motionInfo.lag);
for (unsigned i = 0 ; i < 3; ++i)
PosMsg->position[i] = XDR_encode_double (motionInfo.position(i));
SGVec3f angleAxis;
motionInfo.orientation.getAngleAxis(angleAxis);
for (unsigned i = 0 ; i < 3; ++i)
PosMsg->orientation[i] = XDR_encode_float (angleAxis(i));
for (unsigned i = 0 ; i < 3; ++i)
PosMsg->linearVel[i] = XDR_encode_float (motionInfo.linearVel(i));
for (unsigned i = 0 ; i < 3; ++i)
PosMsg->angularVel[i] = XDR_encode_float (motionInfo.angularVel(i));
for (unsigned i = 0 ; i < 3; ++i)
PosMsg->linearAccel[i] = XDR_encode_float (motionInfo.linearAccel(i));
for (unsigned i = 0 ; i < 3; ++i)
PosMsg->angularAccel[i] = XDR_encode_float (motionInfo.angularAccel(i));
xdr_data_t* ptr = msgBuf.properties();
std::vector<FGPropertyData*>::const_iterator it;
it = motionInfo.properties.begin();
//cout << "OUTPUT PROPERTIES\n";
xdr_data_t* msgEnd = msgBuf.propsEnd();
while (it != motionInfo.properties.end() && ptr + 2 < msgEnd) {
// First element is the ID. Write it out when we know we have room for
// the whole property.
xdr_data_t id = XDR_encode_uint32((*it)->id);
// The actual data representation depends on the type
switch ((*it)->type) {
case simgear::props::INT:
case simgear::props::BOOL:
case simgear::props::LONG:
*ptr++ = id;
*ptr++ = XDR_encode_uint32((*it)->int_value);
//cout << "Prop:" << (*it)->id << " " << (*it)->type << " "<< (*it)->int_value << "\n";
break;
case simgear::props::FLOAT:
case simgear::props::DOUBLE:
*ptr++ = id;
*ptr++ = XDR_encode_float((*it)->float_value);
//cout << "Prop:" << (*it)->id << " " << (*it)->type << " "<< (*it)->float_value << "\n";
break;
case simgear::props::STRING:
case simgear::props::UNSPECIFIED:
{
// String is complicated. It consists of
// The length of the string
// The string itself
// Padding to the nearest 4-bytes.
const char* lcharptr = (*it)->string_value;
if (lcharptr != 0)
{
// Add the length
////cout << "String length: " << strlen(lcharptr) << "\n";
uint32_t len = strlen(lcharptr);
if (len > MAX_TEXT_SIZE)
len = MAX_TEXT_SIZE;
// XXX This should not be using 4 bytes per character!
// If there's not enough room for this property, drop it
// on the floor.
if (ptr + 2 + ((len + 3) & ~3) > msgEnd)
goto escape;
//cout << "String length unint32: " << len << "\n";
*ptr++ = id;
*ptr++ = XDR_encode_uint32(len);
if (len != 0)
{
// Now the text itself
// XXX This should not be using 4 bytes per character!
int lcount = 0;
while ((*lcharptr != '\0') && (lcount < MAX_TEXT_SIZE))
{
*ptr++ = XDR_encode_int8(*lcharptr);
lcharptr++;
lcount++;
}
//cout << "Prop:" << (*it)->id << " " << (*it)->type << " " << len << " " << (*it)->string_value;
// Now pad if required
while ((lcount % 4) != 0)
{
*ptr++ = XDR_encode_int8(0);
lcount++;
//cout << "0";
}
//cout << "\n";
}
}
else
{
// Nothing to encode
*ptr++ = id;
*ptr++ = XDR_encode_uint32(0);
//cout << "Prop:" << (*it)->id << " " << (*it)->type << " 0\n";
}
}
break;
default:
//cout << " Unknown Type: " << (*it)->type << "\n";
*ptr++ = id;
*ptr++ = XDR_encode_float((*it)->float_value);;
//cout << "Prop:" << (*it)->id << " " << (*it)->type << " "<< (*it)->float_value << "\n";
break;
}
++it;
}
escape:
msgLen = reinterpret_cast<char*>(ptr) - msgBuf.Msg;
FillMsgHdr(msgBuf.msgHdr(), POS_DATA_ID, msgLen);
}
if (msgLen>0)
mSocket->sendto(msgBuf.Msg, msgLen, 0, &mServer);
SG_LOG(SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::SendMyPosition"); SG_LOG(SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::SendMyPosition");
} // FGMultiplayMgr::SendMyPosition() } // FGMultiplayMgr::SendMyPosition()