Merged fixes to warnings in geo plugin from Geoff.
This commit is contained in:
@@ -86,7 +86,7 @@ void geoHeaderGeo::addUserVar(const georecord &gr)
|
||||
//== handler for updating internal variables
|
||||
void geoHeaderGeo::update(void)
|
||||
{ // update the scene
|
||||
osg::Timer_t _frameTick = _timer.tick();;
|
||||
osg::Timer_t _frameTick = _timer.tick();
|
||||
_lastFrameTick=_frameTick;
|
||||
|
||||
_frameStamp.setFrameNumber(_frameStamp.getFrameNumber()+1);
|
||||
@@ -224,7 +224,7 @@ public:
|
||||
cb->setColorPalette(ghdr->getColorPalette());
|
||||
cb->setVertIndices(ncoord-1,1); // part of colours array to be modified
|
||||
bool ok=cb->makeBehave((*rcitr), ghdr);
|
||||
BehList.push_back(cb);
|
||||
if (ok) BehList.push_back(cb);
|
||||
} // if the model does not use vertex colours... there can be no colour animation at vertex level
|
||||
}
|
||||
}
|
||||
@@ -250,7 +250,7 @@ public:
|
||||
float red=cp[0]/255.0f;
|
||||
float green=cp[1]/255.0f;
|
||||
float blue=cp[2]/255.0f;
|
||||
float alpha=cp[3]/255.0f;
|
||||
// may need alpha in future:: float alpha=cp[3]/255.0f;
|
||||
colors->push_back(Vec4(red,green,blue,1.0));
|
||||
} else { // look for a colour index (exclusive!)
|
||||
gfd=gr->getField(GEO_DB_VRTX_COLOR_INDEX);
|
||||
@@ -376,7 +376,7 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
gr.readfile(fin);
|
||||
//if (gr.getType() != DB_DSK_INSTANCE) gr.writefile(fdup); // create a duplicate file
|
||||
if (gr.getType() == DB_DSK_NORMAL_POOL) {
|
||||
geoField *gfff=gr.getModField(GEO_DB_NORMAL_POOL_VALUES);;
|
||||
geoField *gfff=gr.getModField(GEO_DB_NORMAL_POOL_VALUES);
|
||||
gfff->uncompress();// uncompress the normals
|
||||
}
|
||||
recs.push_back(gr); // add to a list of all records
|
||||
@@ -571,7 +571,7 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
}
|
||||
return one;
|
||||
}
|
||||
osg::Geometry *makeNewGeometry(const georecord *grec, geoInfo &ginf, uint imat) {
|
||||
osg::Geometry *makeNewGeometry(const georecord *grec, geoInfo &ginf, int imat) {
|
||||
const int shademodel=ginf.getShademodel();
|
||||
const bool bothsides=ginf.getBothsides();
|
||||
osg::Geometry *nug;
|
||||
@@ -602,7 +602,7 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
}
|
||||
}
|
||||
}
|
||||
if (imat<0 || imat>=matlist.size()) imat=0;
|
||||
if (imat<0 || imat>=(int)matlist.size()) imat=0;
|
||||
const geoField *gfd=grec->getField(GEO_DB_POLY_USE_MATERIAL_DIFFUSE); // true: use material...
|
||||
bool usemat= gfd ? gfd->getBool() : false;
|
||||
if (!usemat) {
|
||||
@@ -674,10 +674,11 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
for (std::vector<georecord *>::const_iterator itr=gr.begin();
|
||||
itr!=gr.end();
|
||||
++itr) {
|
||||
bool hbeh=vinf->addIndices((*itr), theHeader, defcol, grec);
|
||||
if (hbeh) { // then add a behaviour callback to the primitive
|
||||
bool hasbehave=true;
|
||||
}
|
||||
//bool hbeh=
|
||||
vinf->addIndices((*itr), theHeader, defcol, grec);
|
||||
//if (hbeh) { // then add a behaviour callback to the primitive
|
||||
// bool hasbehave=true;
|
||||
//}
|
||||
nv++;
|
||||
}
|
||||
}
|
||||
@@ -732,10 +733,6 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
gfd=gr->getField(GEO_DB_TEXT_COLOR_INDEX);
|
||||
if (gfd) {
|
||||
int icp=gfd->getInt();
|
||||
float red=1.0f; // convert to range {0-1}
|
||||
float green=1.0f;
|
||||
float blue=1.0f;
|
||||
float alpha=1.0f;
|
||||
float col[4];
|
||||
theHeader->getPalette(icp,col);
|
||||
text->setColor(osg::Vec4(col[0],col[1],col[2],1.0));
|
||||
@@ -828,7 +825,7 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
float red=cls[0]/255.0f;
|
||||
float green=cls[1]/255.0f;
|
||||
float blue=cls[2]/255.0f;
|
||||
float alpha=1.0f; // cls[3]*frac/255.0f;
|
||||
//float alpha=1.0f; // cls[3]*frac/255.0f;
|
||||
osg::Vec4 colour(red,green,blue,1.0f);
|
||||
lpn->addLightPoint(osgSim::LightPoint(true,coord_pool[idx],colour,1.0f,1.0f,30,0,0,osgSim::LightPoint::BLENDED));
|
||||
} else { // get colour from palette
|
||||
@@ -848,16 +845,16 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
++itr)
|
||||
{
|
||||
if ((*itr)->getType()==DB_DSK_LIGHTPT) { // light points ONLY
|
||||
geoInfo ginf(0,0, true);;
|
||||
geoInfo ginf(0,0, true);
|
||||
ginf.setPools(&coord_pool, &normal_pool); // holds all types of coords, indices etc
|
||||
osgSim::LightPointNode *gd=new osgSim::LightPointNode;
|
||||
const geoField *gfd=(*itr)->getField(GEO_DB_LIGHTPT_TYPE); // omni, uni, bi
|
||||
// to be implemented const geoField *gfd=(*itr)->getField(GEO_DB_LIGHTPT_TYPE); // omni, uni, bi
|
||||
makeLightPointNode((*itr),gd); // add vertex positions to light point set
|
||||
nug->addChild(gd);
|
||||
}
|
||||
}
|
||||
}
|
||||
void makeAnimatedGeometry(const georecord grec, const unsigned int imat,Group *nug) {
|
||||
void makeAnimatedGeometry(const georecord grec, const int imat,Group *nug) {
|
||||
// animated polygons - create a matrix & geode & poly & add to group nug
|
||||
const std::vector<georecord *> gr=grec.getchildren();
|
||||
bool bothsides=allOneSided(&grec);
|
||||
@@ -873,7 +870,7 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
int shademodel=gfd ? gfd->getInt() : GEO_POLY_SHADEMODEL_LIT_GOURAUD;
|
||||
gfd=(*itr)->getField(GEO_DB_POLY_USE_MATERIAL_DIFFUSE); // true: use material...
|
||||
bool usemat= gfd ? gfd->getBool() : false;
|
||||
geoInfo ginf(txidx,shademodel, bothsides);;
|
||||
geoInfo ginf(txidx,shademodel, bothsides);
|
||||
ginf.setPools(&coord_pool, &normal_pool); // holds all types of coords, indices etc
|
||||
MatrixTransform *mtr=makeBehave(*itr);
|
||||
Geode *gd=new Geode;
|
||||
@@ -1084,7 +1081,7 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
// - we need to create this tree to render text
|
||||
Group *nug=new Group;
|
||||
const geoField *gfd=gr->getField(GEO_DB_RENDERGROUP_MAT);
|
||||
const unsigned int imat=gfd ? gfd->getInt():0;
|
||||
// may be used in future const unsigned int imat=gfd ? gfd->getInt():0;
|
||||
gfd=gr->getField(GEO_DB_RENDERGROUP_NAME);
|
||||
if (gfd) {
|
||||
nug->setName(gfd->getChar());
|
||||
@@ -1100,7 +1097,6 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
char *name = gfd->getChar();
|
||||
nug->setName(name);
|
||||
}
|
||||
Geode *gd=new Geode;
|
||||
makeLightPointGeometry(gr,nug);
|
||||
if (nug->getNumChildren() <=0) {
|
||||
nug=NULL;
|
||||
@@ -1112,9 +1108,9 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
// movement actions require a transform node to be inserted, and this cannot be
|
||||
// derived from Geode. So create a group, add matrix transform(s) for each animated polygon
|
||||
const geoField *gfd=gr->getField(GEO_DB_RENDERGROUP_MAT);
|
||||
const unsigned int imat=gfd ? gfd->getInt():0;
|
||||
gfd=gr->getField(GEO_DB_RENDERGROUP_IS_BILLBOARD);
|
||||
bool isbillb = gfd ? gfd->getBool() : false;
|
||||
const int imat=gfd ? gfd->getInt():0;
|
||||
// gfd=gr->getField(GEO_DB_RENDERGROUP_IS_BILLBOARD);
|
||||
// bool isbillb = gfd ? gfd->getBool() : false;
|
||||
Group *nug=new Group;
|
||||
/* if (isbillb) {
|
||||
Billboard *bilb= new Billboard ;
|
||||
@@ -1199,7 +1195,7 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
int selector_mask = 0x1;
|
||||
for(int pos=0;pos<32;++pos)
|
||||
{
|
||||
sw->setValue(pos,imask&selector_mask);
|
||||
sw->setValue(pos,((imask&selector_mask)?true:false));
|
||||
selector_mask <<= 1;
|
||||
}
|
||||
osg::notify(osg::WARN) << gr << " imask " << imask << std::endl;
|
||||
@@ -1454,7 +1450,7 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
break;
|
||||
case DB_DSK_VISIBILITY_ACTION: {
|
||||
geoVisibBehaviour *vb = new geoVisibBehaviour;
|
||||
ok=vb->makeBehave((*rcitr), theHeader, DB_DSK_VISIBILITY_ACTION);
|
||||
ok=vb->makeBehave((*rcitr), theHeader);
|
||||
if (ok) gcb->addBehaviour(vb);
|
||||
else delete vb;
|
||||
}
|
||||
@@ -1850,7 +1846,6 @@ void userVars::addUserVar(const georecord &gr) {
|
||||
|
||||
void internalVars::update(osg::Timer &_timer,osg::FrameStamp &_frameStamp) {
|
||||
double stmptime=_frameStamp.getReferenceTime();
|
||||
osg::Timer_t _frameTick = _timer.tick();;
|
||||
int iord=0;
|
||||
for (std::vector<geoValue>::const_iterator itr=vars.begin(); //gfl.begin();
|
||||
itr!=vars.end(); // gfl.end();
|
||||
|
||||
@@ -185,11 +185,11 @@ void geoCompareBehaviour::doaction(void) const { // do compare operation
|
||||
if (in && out) {
|
||||
double var2=varop? *varop : constant;
|
||||
switch (oper) {
|
||||
case 1: oper; *out = (*in < var2) ? 1.0: -1.0; break;// Less
|
||||
case 2: oper; *out = (*in <= var2) ? 1.0: -1.0; break;//=LessOREQ
|
||||
case 3: oper; *out = (*in > var2) ? 1.0: -1.0; break; // greater...
|
||||
case 4: oper; *out = (*in >= var2) ? 1.0: -1.0; break;
|
||||
case 5: oper; *out = (*in == var2) ? 1.0: -1.0; break;
|
||||
case 1: *out = (*in < var2) ? 1.0: -1.0; break;// Less
|
||||
case 2: *out = (*in <= var2) ? 1.0: -1.0; break;//=LessOREQ
|
||||
case 3: *out = (*in > var2) ? 1.0: -1.0; break; // greater...
|
||||
case 4: *out = (*in >= var2) ? 1.0: -1.0; break;
|
||||
case 5: *out = (*in == var2) ? 1.0: -1.0; break;
|
||||
case UNKNOWN: break;
|
||||
}
|
||||
}
|
||||
@@ -409,7 +409,7 @@ bool geoMoveBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *the
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
void geoMoveVertexBehaviour::doaction(Matrix &mtr,osg::Drawable *dr) {
|
||||
void geoMoveVertexBehaviour::doaction(Matrix &mtr) {
|
||||
// update the matrix mtr
|
||||
if (getVar()) {
|
||||
switch (getType()) {
|
||||
@@ -478,7 +478,7 @@ bool geoMoveVertexBehaviour::makeBehave(const georecord *grec, const geoHeaderGe
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool geoVisibBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader, const uint act) {
|
||||
bool geoVisibBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) {
|
||||
bool ok=false;
|
||||
const geoField *gfd= grec->getField(GEO_DB_VISIBILITY_ACTION_INPUT_VAR);
|
||||
if (gfd) {
|
||||
@@ -519,7 +519,8 @@ bool geoColourBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *t
|
||||
void geoColourBehaviour::doaction(osg::Drawable *dr) const
|
||||
{ // do visibility operation on Node
|
||||
if (getVar()) {
|
||||
uint idx=getValue();
|
||||
double val=getValue();
|
||||
uint idx=(uint)val;
|
||||
osg::Geometry *gm=dynamic_cast<osg::Geometry *>(dr);
|
||||
if (gm) {
|
||||
osg::Vec4Array* cla = dynamic_cast<osg::Vec4Array*>(gm->getColorArray());
|
||||
@@ -640,7 +641,7 @@ void geoBehaviourDrawableCB::app(osg::NodeVisitor *,osg::Drawable *dr) {
|
||||
if (clrb) clrb->doaction(dr);
|
||||
geoMoveVertexBehaviour *mvvb=dynamic_cast<geoMoveVertexBehaviour *>(*itr);
|
||||
if (mvvb && (prevvtr<0 || prevvtr==mvvb->getindex())) {
|
||||
mvvb->doaction(mtr,dr);
|
||||
mvvb->doaction(mtr);
|
||||
pos=mvvb->getpos();
|
||||
prevvtr=mvvb->getindex();
|
||||
}
|
||||
@@ -660,7 +661,7 @@ void geoBehaviourDrawableCB::app(osg::NodeVisitor *,osg::Drawable *dr) {
|
||||
if (mvvb) {
|
||||
int vidx=mvvb->getindex();
|
||||
if (mvvb && (prevvtr<vidx || (newpos && prevvtr==vidx))) {
|
||||
mvvb->doaction(mtr,dr);
|
||||
mvvb->doaction(mtr);
|
||||
prevvtr=vidx;
|
||||
pos=mvvb->getpos();
|
||||
newpos=true;
|
||||
|
||||
@@ -224,10 +224,10 @@ const unsigned char SIZEOF_BITFLAGS = (SIZEOF_INT);
|
||||
|
||||
|
||||
|
||||
const unsigned short MIN_CHAR_VAL = -128;
|
||||
const short MIN_CHAR_VAL = -128;
|
||||
const unsigned short MAX_CHAR_VAL = 127;
|
||||
const unsigned short MAX_UCHAR_VAL = 255;
|
||||
const unsigned short MIN_SHORT_VAL = -32768;
|
||||
const short MIN_SHORT_VAL = -32768;
|
||||
const unsigned short MAX_SHORT_VAL = 32767;
|
||||
const unsigned short MAX_USHORT_VAL = 65535;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ inline double addv(const double var1,const double var2) { return var1+var2; }
|
||||
inline double subv(const double var1,const double var2) { return var1-var2; }
|
||||
inline double mulv(const double var1,const double var2) { return var1*var2; }
|
||||
inline double divv(const double var1,const double var2) { return var1/var2; }
|
||||
inline double equa(const double var1,const double var2) { return var1; }
|
||||
inline double equa(const double var1,const double var2) { return var1==var2; }
|
||||
inline double linear(const double var1,const double var2,const double var3) { return var2*var1+var3; }
|
||||
inline double lininv(const double var1,const double var2,const double var3) { return var2/var1+var3; }
|
||||
inline double linmod(const double var1,const double var2,const double var3) { return var2*fmod(var1,var3); }
|
||||
@@ -190,10 +190,10 @@ public:
|
||||
inline unsigned int getType(void) const { return type;}
|
||||
inline const double *getVar(void) const { return var;}
|
||||
inline double getValue(void) const { return *var;}
|
||||
virtual void doaction(osg::Node *node) const {
|
||||
virtual void doaction(osg::Node *) const {
|
||||
}
|
||||
|
||||
virtual bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader, const uint act) {
|
||||
virtual bool makeBehave(const georecord *, geoHeaderGeo *, const uint ) {
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
@@ -225,7 +225,7 @@ public:
|
||||
void setpos(const osg::Vec3 p) { pos=p;}
|
||||
void setindx(const int idx) { index=idx;}
|
||||
inline int getindex(void) const { return index;}
|
||||
void doaction(Matrix &mtr,osg::Drawable *dr);
|
||||
void doaction(Matrix &mtr);
|
||||
|
||||
bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader, const uint act);
|
||||
private:
|
||||
@@ -240,7 +240,7 @@ public:
|
||||
geoVisibBehaviour() { }
|
||||
virtual ~geoVisibBehaviour() { }
|
||||
|
||||
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader, const uint act);
|
||||
bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
|
||||
void doaction(osg::Node *node) const;
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -144,7 +144,7 @@ public:
|
||||
unsigned char col[4];
|
||||
(*color_palette)[maxcol].get(col);
|
||||
for (int i=0; i<4; i++) {
|
||||
col[i]*=frac;
|
||||
col[i]=(unsigned char)(col[i]*frac); // prevents warning under gcc from *=frac with frac=real
|
||||
cll[i]=col[i]/255.0f;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -148,7 +148,6 @@ public:
|
||||
void writefile(std::ofstream &fout) { // write binary file
|
||||
if (numItems<32767 && tokenId<256) {
|
||||
osg::uchar tokid=tokenId, type=TypeId;
|
||||
osg::ushort nits=numItems;
|
||||
fout.write((char *)&tokid, 1);fout.write((char *)&type,1);
|
||||
fout.write((char *)&numItems,sizeof(unsigned short));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user