Patch to fix valgrind errors and gcc warnings from Daniel K.O.
Use #ifdef FOO instead of #if FOO Unused function parameter names Uninitialised member in FrameTree Memory read after deallocation in ReferenceFrame Unmatched new[]/delete[] in StarDatabase Uninitialised temperature in StarDatabase Uninitialised member of RenderListEntry: isOpaque Fix for convoluted code in rendererpull/3/head
parent
3f8d95466e
commit
207823b1d8
|
@ -302,7 +302,7 @@ Matrix4f readMeshMatrix(ifstream& in/*, int nBytes*/)
|
|||
m30, m31, m32, 1;
|
||||
|
||||
return m;
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
return Mat4f(Vec4f(m00, m01, m02, 0),
|
||||
Vec4f(m10, m11, m12, 0),
|
||||
Vec4f(m20, m21, m22, 0),
|
||||
|
|
|
@ -477,7 +477,7 @@ Command* CommandParser::parseCommand()
|
|||
Eigen::Vector3f basef = base.cast<float>();
|
||||
UniversalCoord basePosition = UniversalCoord::CreateLy(basef.cast<double>());
|
||||
cmd = new CommandSetPosition(basePosition.offsetKm(offset));
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
cmd = new CommandSetPosition(astro::universalPosition(Point3d(offset.x, offset.y, offset.z),
|
||||
Point3f((float) base.x, (float) base.y, (float) base.z)));
|
||||
#endif
|
||||
|
|
|
@ -206,7 +206,7 @@ bool DeepSkyObject::load(AssociativeArray* params, const string& resPath)
|
|||
params->getAngle("Angle", angle);
|
||||
|
||||
setOrientation(Quaternionf(AngleAxisf((float) degToRad(angle), axis.cast<float>().normalized())));
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
Quatf q(1);
|
||||
q.setAxisAngle(Vec3f((float) axis.x, (float) axis.y, (float) axis.z),
|
||||
(float) degToRad(angle));
|
||||
|
|
|
@ -34,7 +34,7 @@ bool dsoStraddlesNodesPredicate(const Vector3d& cellCenterPos, DeepSkyObject* co
|
|||
float dsoRadius = _dso->getBoundingSphereRadius();
|
||||
|
||||
return (_dso->getPosition() - cellCenterPos).cwise().abs().minCoeff() < dsoRadius;
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
return abs(dsoPos.x - cellCenterPos.x) < dsoRadius ||
|
||||
abs(dsoPos.y - cellCenterPos.y) < dsoRadius ||
|
||||
abs(dsoPos.z - cellCenterPos.z) < dsoRadius;
|
||||
|
@ -91,7 +91,7 @@ void DSOOctree::processVisibleObjects(DSOHandler& processor,
|
|||
if (plane.signedDistance(cellCenterPos) < -r)
|
||||
return;
|
||||
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
double r = scale * (abs(plane->normal.x) +
|
||||
abs(plane->normal.y) +
|
||||
abs(plane->normal.z));
|
||||
|
|
|
@ -43,10 +43,11 @@ ReferenceFrame::release() const
|
|||
{
|
||||
--refCount;
|
||||
assert(refCount >= 0);
|
||||
int refCountCopy = refCount;
|
||||
if (refCount <= 0)
|
||||
delete this;
|
||||
|
||||
return refCount;
|
||||
return refCountCopy;
|
||||
}
|
||||
|
||||
|
||||
|
@ -175,7 +176,7 @@ ReferenceFrame::getAngularVelocity(double tjd) const
|
|||
return Vector3d::Zero();
|
||||
else
|
||||
return dq.vec().normalized() * (2.0 * acos(dq.w()) / ANGULAR_VELOCITY_DIFF_DELTA);
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
Vector3d v(dq.x, dq.y, dq.z);
|
||||
v.normalize();
|
||||
return v * (2.0 * acos(dq.w) / ANGULAR_VELOCITY_DIFF_DELTA);
|
||||
|
@ -619,7 +620,7 @@ TwoVectorFrame::computeOrientation(double tjd) const
|
|||
rhAxis = 1;
|
||||
bool rhOrder = rhAxis == abs(secondaryAxis);
|
||||
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
// Set the rotation matrix axes
|
||||
Vector3d v[3];
|
||||
v[abs(primaryAxis) - 1] = v0;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
FrameTree::FrameTree(Star* star) :
|
||||
starParent(star),
|
||||
bodyParent(NULL),
|
||||
m_changed(true),
|
||||
defaultFrame(NULL)
|
||||
{
|
||||
// Default frame for a star is J2000 ecliptical, centered
|
||||
|
@ -57,6 +58,7 @@ FrameTree::FrameTree(Star* star) :
|
|||
FrameTree::FrameTree(Body* body) :
|
||||
starParent(NULL),
|
||||
bodyParent(body),
|
||||
m_changed(true),
|
||||
defaultFrame(NULL)
|
||||
{
|
||||
// Default frame for a solar system body is the mean equatorial frame of the body.
|
||||
|
|
|
@ -553,7 +553,7 @@ Image* LoadJPEGImage(const string& filename, int)
|
|||
|
||||
return img;
|
||||
|
||||
#elif TARGET_OS_MAC
|
||||
#elif defined(TARGET_OS_MAC)
|
||||
|
||||
Image* img = NULL;
|
||||
CGBuffer* cgJpegImage;
|
||||
|
|
|
@ -276,7 +276,7 @@ lookAt(Matrix<T, 3, 1> from, Matrix<T, 3, 1> to, Matrix<T, 3, 1> up)
|
|||
return Quaternion<T>(m).conjugate();
|
||||
}
|
||||
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
template<class T> static Quat<T>
|
||||
lookAt(Point3<T> from, Point3<T> to, Vector3<T> up)
|
||||
{
|
||||
|
@ -322,7 +322,7 @@ void Observer::update(double dt, double timeScale)
|
|||
t = (float) clamp((realTime - journey.startTime) / journey.duration);
|
||||
|
||||
Vector3d jv = journey.to.offsetFromKm(journey.from);
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
Vector3d jv = journey.to - journey.from;
|
||||
#endif
|
||||
UniversalCoord p;
|
||||
|
@ -360,7 +360,7 @@ void Observer::update(double dt, double timeScale)
|
|||
p = journey.from.offsetKm(v * x);
|
||||
else
|
||||
p = journey.to.offsetKm(-v * x);
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
if (t < 0.5)
|
||||
p = journey.from + v * astro::kilometersToMicroLightYears(x);
|
||||
else
|
||||
|
@ -404,7 +404,7 @@ void Observer::update(double dt, double timeScale)
|
|||
v = slerp(x, v1, v0);
|
||||
|
||||
p = frame->convertFromUniversal(origin.offsetKm(v), simTime);
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
x = astro::kilometersToMicroLightYears(x / jv.length());
|
||||
Vector3d v;
|
||||
|
||||
|
@ -463,7 +463,7 @@ void Observer::update(double dt, double timeScale)
|
|||
}
|
||||
|
||||
q = journey.initialOrientation.slerp(v, journey.finalOrientation);
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
// Be careful to choose the shortest path when interpolating
|
||||
if ((journey.initialOrientation.coeffs() - journey.finalOrientation.coeffs()).norm() <
|
||||
(journey.initialOrientation.coeffs() + journey.finalOrientation.coeffs()).norm())
|
||||
|
@ -524,7 +524,7 @@ void Observer::update(double dt, double timeScale)
|
|||
Quaterniond dr = Quaterniond(0.0, halfAV.x(), halfAV.y(), halfAV.z()) * orientation;
|
||||
orientation = Quaterniond(orientation.coeffs() + dt * dr.coeffs());
|
||||
orientation.normalize();
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
Quaterniond dr = 0.5 * (AV * orientation);
|
||||
orientation += dt * dr;
|
||||
orientation.normalize();
|
||||
|
@ -584,7 +584,7 @@ void Observer::setLocationFilter(uint32 _locationFilter)
|
|||
void Observer::reverseOrientation()
|
||||
{
|
||||
setOrientation(getOrientation() * Quaterniond(AngleAxisd(PI, Vector3d::UnitY())));
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
Quatd q = getOrientation();
|
||||
q.yrotate(PI);
|
||||
setOrientation(q);
|
||||
|
|
|
@ -244,7 +244,7 @@ Color Renderer::EclipticColor (0.5f, 0.1f, 0.1f);
|
|||
Color Renderer::SelectionCursorColor (1.0f, 0.0f, 0.0f);
|
||||
|
||||
|
||||
#if ENABLE_SELF_SHADOW
|
||||
#ifdef ENABLE_SELF_SHADOW
|
||||
static FramebufferObject* shadowFbo = NULL;
|
||||
#endif
|
||||
|
||||
|
@ -1144,7 +1144,7 @@ bool Renderer::init(GLContext* _context,
|
|||
genBlurTextures();
|
||||
#endif
|
||||
|
||||
#if ENABLE_SELF_SHADOW
|
||||
#ifdef ENABLE_SELF_SHADOW
|
||||
if (GLEW_EXT_framebuffer_object)
|
||||
{
|
||||
shadowFbo = new FramebufferObject(1024, 1024, FramebufferObject::DepthAttachment);
|
||||
|
@ -1539,18 +1539,14 @@ void Renderer::addAnnotation(vector<Annotation>& annotations,
|
|||
float size)
|
||||
{
|
||||
double winX, winY, winZ;
|
||||
int view[4] = { 0, 0, 0, 0 };
|
||||
view[0] = -windowWidth / 2;
|
||||
view[1] = -windowHeight / 2;
|
||||
view[2] = windowWidth;
|
||||
view[3] = windowHeight;
|
||||
GLint view[4] = { 0, 0, windowWidth, windowHeight };
|
||||
float depth = (float) (pos.x() * modelMatrix[2] +
|
||||
pos.y() * modelMatrix[6] +
|
||||
pos.z() * modelMatrix[10]);
|
||||
if (gluProject(pos.x(), pos.y(), pos.z(),
|
||||
modelMatrix,
|
||||
projMatrix,
|
||||
(const GLint*) view,
|
||||
view,
|
||||
&winX, &winY, &winZ) != GL_FALSE)
|
||||
{
|
||||
Annotation a;
|
||||
|
@ -1603,18 +1599,14 @@ void Renderer::addSortedAnnotation(const MarkerRepresentation* markerRep,
|
|||
float size)
|
||||
{
|
||||
double winX, winY, winZ;
|
||||
int view[4] = { 0, 0, 0, 0 };
|
||||
view[0] = -windowWidth / 2;
|
||||
view[1] = -windowHeight / 2;
|
||||
view[2] = windowWidth;
|
||||
view[3] = windowHeight;
|
||||
GLint view[4] = { 0, 0, windowWidth, windowHeight };
|
||||
float depth = (float) (pos.x() * modelMatrix[2] +
|
||||
pos.y() * modelMatrix[6] +
|
||||
pos.z() * modelMatrix[10]);
|
||||
if (gluProject(pos.x(), pos.y(), pos.z(),
|
||||
modelMatrix,
|
||||
projMatrix,
|
||||
(const GLint*) view,
|
||||
view,
|
||||
&winX, &winY, &winZ) != GL_FALSE)
|
||||
{
|
||||
Annotation a;
|
||||
|
@ -1701,18 +1693,14 @@ void Renderer::addObjectAnnotation(const MarkerRepresentation* markerRep,
|
|||
if (objectAnnotationSetOpen)
|
||||
{
|
||||
double winX, winY, winZ;
|
||||
int view[4] = { 0, 0, 0, 0 };
|
||||
view[0] = -windowWidth / 2;
|
||||
view[1] = -windowHeight / 2;
|
||||
view[2] = windowWidth;
|
||||
view[3] = windowHeight;
|
||||
GLint view[4] = { 0, 0, windowWidth, windowHeight };
|
||||
float depth = (float) (pos.x() * modelMatrix[2] +
|
||||
pos.y() * modelMatrix[6] +
|
||||
pos.z() * modelMatrix[10]);
|
||||
if (gluProject(pos.x(), pos.y(), pos.z(),
|
||||
modelMatrix,
|
||||
projMatrix,
|
||||
(const GLint*) view,
|
||||
view,
|
||||
&winX, &winY, &winZ) != GL_FALSE)
|
||||
{
|
||||
|
||||
|
@ -3944,7 +3932,7 @@ void Renderer::draw(const Observer& observer,
|
|||
}
|
||||
#endif
|
||||
|
||||
#if VIDEO_SYNC
|
||||
#ifdef VIDEO_SYNC
|
||||
if (videoSync && glXWaitVideoSyncSGI != NULL)
|
||||
{
|
||||
unsigned int count;
|
||||
|
@ -9364,6 +9352,7 @@ void PointStarRenderer::process(const Star& star, float distance, float appMag)
|
|||
rle.radius = star.getRadius();
|
||||
rle.discSizeInPixels = discSizeInPixels;
|
||||
rle.appMag = appMag;
|
||||
rle.isOpaque = true;
|
||||
renderList->insert(renderList->end(), rle);
|
||||
}
|
||||
}
|
||||
|
@ -10189,8 +10178,6 @@ void Renderer::renderAnnotations(const vector<Annotation>& annotations, FontStyl
|
|||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glTranslatef(GLfloat((int) (windowWidth / 2)),
|
||||
GLfloat((int) (windowHeight / 2)), 0);
|
||||
|
||||
for (int i = 0; i < (int) annotations.size(); i++)
|
||||
{
|
||||
|
@ -10328,8 +10315,6 @@ Renderer::renderSortedAnnotations(vector<Annotation>::iterator iter,
|
|||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glTranslatef(GLfloat((int) (windowWidth / 2)),
|
||||
GLfloat((int) (windowHeight / 2)), 0);
|
||||
|
||||
// Precompute values that will be used to generate the normalized device z value;
|
||||
// we're effectively just handling the projection instead of OpenGL. We use an orthographic
|
||||
|
@ -10419,8 +10404,6 @@ Renderer::renderAnnotations(vector<Annotation>::iterator startIter,
|
|||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glTranslatef(GLfloat((int) (windowWidth / 2)),
|
||||
GLfloat((int) (windowHeight / 2)), 0);
|
||||
|
||||
// Precompute values that will be used to generate the normalized device z value;
|
||||
// we're effectively just handling the projection instead of OpenGL. We use an orthographic
|
||||
|
|
|
@ -394,7 +394,7 @@ void renderClouds_GLSL(const RenderInfo& ri,
|
|||
Texture* cloudNormalMap,
|
||||
float texOffset,
|
||||
const Vector3f& semiAxes,
|
||||
unsigned int textureRes,
|
||||
unsigned int /*textureRes*/,
|
||||
int renderFlags,
|
||||
const Quaternionf& planetOrientation,
|
||||
const Frustum& frustum,
|
||||
|
|
|
@ -739,7 +739,7 @@ void StarDatabase::finish()
|
|||
buildIndexes();
|
||||
|
||||
// Delete the temporary indices used only during loading
|
||||
delete binFileCatalogNumberIndex;
|
||||
delete[] binFileCatalogNumberIndex;
|
||||
stcFileCatalogNumberIndex.clear();
|
||||
|
||||
// Resolve all barycenters; this can't be done before star sorting. There's
|
||||
|
@ -867,7 +867,7 @@ bool StarDatabase::createStar(Star* star,
|
|||
double radius;
|
||||
bool hasRadius = starData->getLength("Radius", radius);
|
||||
|
||||
double temperature;
|
||||
double temperature = 0.0;
|
||||
bool hasTemperature = starData->getNumber("Temperature", temperature);
|
||||
// disallow unphysical temperature values
|
||||
if (temperature <= 0.0)
|
||||
|
@ -1404,7 +1404,7 @@ void StarDatabase::buildOctree()
|
|||
DPRINTF(1, "%d stars total\n", (int) (firstStar - sortedStars));
|
||||
DPRINTF(1, "Octree has %d nodes and %d stars.\n",
|
||||
1 + octreeRoot->countChildren(), octreeRoot->countObjects());
|
||||
#if PROFILE_OCTREE
|
||||
#ifdef PROFILE_OCTREE
|
||||
vector<OctreeLevelStatistics> stats;
|
||||
octreeRoot->computeStatistics(stats);
|
||||
for (vector<OctreeLevelStatistics>::const_iterator iter = stats.begin(); iter != stats.end(); ++iter)
|
||||
|
|
|
@ -3110,7 +3110,7 @@ class JPLEphOrbit : public CachingOrbit
|
|||
}
|
||||
|
||||
// Rotate from the J2000 mean equator to the ecliptic
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
pos = pos * Mat3d::xrotation(astro::J2000Obliquity);
|
||||
#endif
|
||||
pos = XRotation(-astro::J2000Obliquity) * pos;
|
||||
|
|
|
@ -233,7 +233,7 @@ astro::Nutation_IAU2000B(double T)
|
|||
}
|
||||
|
||||
|
||||
#if TEST
|
||||
#ifdef TEST
|
||||
|
||||
using namespace astro;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ RotationModel::angularVelocityAtTime(double tdb) const
|
|||
return Vector3d::Zero();
|
||||
|
||||
return dq.vec().normalized() * (2.0 * acos(dq.w()) / dt);
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
Vector3d v(dq.x, dq.y, dq.z);
|
||||
v.normalize();
|
||||
return v * (2.0 * acos(dq.w) / dt);
|
||||
|
@ -153,7 +153,7 @@ CachingRotationModel::computeAngularVelocity(double tjd) const
|
|||
return Vector3d::Zero();
|
||||
|
||||
return dq.vec().normalized() * (2.0 * acos(dq.w()) / dt);
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
Vec3d v(dq.x, dq.y, dq.z);
|
||||
v.normalize();
|
||||
return v * (2.0 * acos(dq.w) / dt);
|
||||
|
|
|
@ -194,7 +194,7 @@ ScriptedOrbit::computePosition(double tjd) const
|
|||
if (lua_pcall(luaState, 2, 3, 0) == 0)
|
||||
{
|
||||
pos = Vector3d(lua_tonumber(luaState, -3), lua_tonumber(luaState, -2), lua_tonumber(luaState, -1));
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
pos.x = lua_tonumber(luaState, -3);
|
||||
pos.y = lua_tonumber(luaState, -2);
|
||||
pos.z = lua_tonumber(luaState, -1);
|
||||
|
|
|
@ -176,7 +176,7 @@ ScriptedRotation::spin(double tjd) const
|
|||
lua_tonumber(luaState, -3),
|
||||
lua_tonumber(luaState, -2),
|
||||
lua_tonumber(luaState, -1));
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
lastOrientation.w = lua_tonumber(luaState, -4);
|
||||
lastOrientation.x = lua_tonumber(luaState, -3);
|
||||
lastOrientation.y = lua_tonumber(luaState, -2);
|
||||
|
|
|
@ -71,7 +71,7 @@ FavoritesList* ReadFavoritesList(istream& in)
|
|||
favParams->getVector("base", base);
|
||||
favParams->getVector("offset", offset);
|
||||
fav->position = UniversalCoord::CreateLy(base) + UniversalCoord::CreateLy(offset * 1.0e-6);
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
base *= 1e6;
|
||||
fav->position = UniversalCoord(Point3d(base.x, base.y, base.z)) + offset;
|
||||
#endif
|
||||
|
@ -82,7 +82,7 @@ FavoritesList* ReadFavoritesList(istream& in)
|
|||
favParams->getVector("axis", axis);
|
||||
favParams->getNumber("angle", angle);
|
||||
fav->orientation = Quaternionf(AngleAxisf((float) angle, axis.cast<float>()));
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
fav->orientation.setAxisAngle(Vec3f((float) axis.x, (float) axis.y, (float) axis.z),
|
||||
(float) angle);
|
||||
#endif
|
||||
|
@ -135,7 +135,7 @@ void WriteFavoritesList(FavoritesList& favorites, ostream& out)
|
|||
|
||||
// This was the old way of doing things, before the confusing operators
|
||||
// and implicit casts were removed from UniversalCoord.
|
||||
#if CELVEC
|
||||
#ifdef CELVEC
|
||||
Point3d base = (Point3d) fav->position;
|
||||
Vec3d offset = fav->position - base;
|
||||
base.x *= 1e-6; base.y *= 1e-6; base.z *= 1e-6;
|
||||
|
|
|
@ -22,8 +22,10 @@
|
|||
#endif
|
||||
|
||||
// gettext / libintl setup
|
||||
#ifndef _ /* unless somebody already took care of this */
|
||||
#define _(string) gettext (string)
|
||||
#define gettext_noop(string) string
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
|
|
Loading…
Reference in New Issue