parent
743a7e91a7
commit
b082d5f47f
|
@ -14,7 +14,7 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <cstdio>
|
||||
#include <assert.h>
|
||||
#include <cassert>
|
||||
#include <unistd.h>
|
||||
#include "celengine/stardb.h"
|
||||
|
||||
|
@ -48,48 +48,30 @@ static int verbose, dropstars;
|
|||
class HipparcosStar
|
||||
{
|
||||
public:
|
||||
HipparcosStar();
|
||||
HipparcosStar() = default;
|
||||
|
||||
void write(ostream&);
|
||||
void write(ostream& /*out*/);
|
||||
void analyze();
|
||||
|
||||
uint32 HIPCatalogNumber;
|
||||
uint32 HDCatalogNumber;
|
||||
float ascension;
|
||||
float declination;
|
||||
float parallax;
|
||||
float appMag;
|
||||
uint32 HIPCatalogNumber{NullCatalogNumber};
|
||||
uint32 HDCatalogNumber{NullCatalogNumber};
|
||||
float ascension{0.0f};
|
||||
float declination{0.0f};
|
||||
float parallax{0.0f};
|
||||
float appMag{0.0f};
|
||||
StellarClass stellarClass;
|
||||
|
||||
uint32 CCDMIdentifier;
|
||||
uint8 starsWithCCDM;
|
||||
uint8 nComponents;
|
||||
uint8 parallaxError;
|
||||
uint tycline;
|
||||
uint32 CCDMIdentifier{NullCCDMIdentifier};
|
||||
uint8 starsWithCCDM{0};
|
||||
uint8 nComponents{1};
|
||||
uint8 parallaxError{0};
|
||||
uint tycline{0};
|
||||
uint status;
|
||||
float e_RA; // Errors in Right Ascension,
|
||||
float e_DE; // Declination,
|
||||
float e_Mag; // and Magnitude
|
||||
float e_RA{0.0f}; // Errors in Right Ascension,
|
||||
float e_DE{0.0f}; // Declination,
|
||||
float e_Mag{0.0f}; // and Magnitude
|
||||
};
|
||||
|
||||
HipparcosStar::HipparcosStar() :
|
||||
HIPCatalogNumber(NullCatalogNumber),
|
||||
HDCatalogNumber(NullCatalogNumber),
|
||||
ascension(0.0f),
|
||||
declination(0.0f),
|
||||
parallax(0.0f),
|
||||
appMag(0.0f),
|
||||
CCDMIdentifier(NullCCDMIdentifier),
|
||||
starsWithCCDM(0),
|
||||
nComponents(1),
|
||||
parallaxError(0),
|
||||
tycline(0),
|
||||
e_RA(0.0f),
|
||||
e_DE(0.0f),
|
||||
e_Mag(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
template<class T> void binwrite(ostream& out, T x)
|
||||
{
|
||||
out.write(reinterpret_cast<char*>(&x), sizeof(T));
|
||||
|
@ -176,7 +158,7 @@ void HipparcosStar::analyze()
|
|||
status=1;
|
||||
n_dub++;
|
||||
}
|
||||
if ((dubious>5) && (dropstars) && (!(dropstars==1 && appMag<6.0)))
|
||||
if ((dubious>5) && ((dropstars) != 0) && (!(dropstars==1 && appMag<6.0)))
|
||||
{
|
||||
status=2;
|
||||
n_drop++;
|
||||
|
@ -191,7 +173,7 @@ bool operator<(const HipparcosStar& a, const HipparcosStar& b)
|
|||
|
||||
struct HIPCatalogComparePredicate
|
||||
{
|
||||
HIPCatalogComparePredicate() : dummy(0)
|
||||
HIPCatalogComparePredicate()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -205,7 +187,7 @@ struct HIPCatalogComparePredicate
|
|||
return star0->HIPCatalogNumber < hip;
|
||||
}
|
||||
|
||||
int dummy;
|
||||
int dummy{0};
|
||||
};
|
||||
|
||||
|
||||
|
@ -220,35 +202,21 @@ public:
|
|||
class HipparcosComponent
|
||||
{
|
||||
public:
|
||||
HipparcosComponent();
|
||||
HipparcosComponent() = default;
|
||||
|
||||
HipparcosStar* star;
|
||||
char componentID;
|
||||
char refComponentID;
|
||||
HipparcosStar* star{nullptr};
|
||||
char componentID{'A'};
|
||||
char refComponentID{'A'};
|
||||
float ascension;
|
||||
float declination;
|
||||
float appMag;
|
||||
float bMag;
|
||||
float vMag;
|
||||
bool hasBV;
|
||||
float positionAngle;
|
||||
float separation;
|
||||
float appMag{0.0f};
|
||||
float bMag{0.0f};
|
||||
float vMag{0.0f};
|
||||
bool hasBV{false};
|
||||
float positionAngle{0.0f};
|
||||
float separation{0.0f};
|
||||
};
|
||||
|
||||
HipparcosComponent::HipparcosComponent() :
|
||||
star(NULL),
|
||||
componentID('A'),
|
||||
refComponentID('A'),
|
||||
appMag(0.0f),
|
||||
bMag(0.0f),
|
||||
vMag(0.0f),
|
||||
hasBV(false),
|
||||
positionAngle(0.0f),
|
||||
separation(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
vector<HipparcosStar> stars;
|
||||
vector<HipparcosStar> companions;
|
||||
vector<HipparcosComponent> components;
|
||||
|
@ -266,12 +234,12 @@ HipparcosStar* findStar(uint32 hip)
|
|||
starIndex.end(),
|
||||
hip, pred);
|
||||
if (iter == starIndex.end())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
HipparcosStar* star = *iter;
|
||||
if (star->HIPCatalogNumber == hip)
|
||||
return star;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -381,7 +349,8 @@ StellarClass ParseStellarClass(char *starType)
|
|||
lum = StellarClass::Lum_Ib;
|
||||
}
|
||||
break;
|
||||
} else if (starType[i] == 'V') {
|
||||
}
|
||||
if (starType[i] == 'V') {
|
||||
if (starType[i + 1] == 'I')
|
||||
lum = StellarClass::Lum_VI;
|
||||
else
|
||||
|
@ -838,7 +807,7 @@ bool ReadComponentRecord(istream& in)
|
|||
}
|
||||
|
||||
component.star = findStar(hip);
|
||||
if (component.star == NULL)
|
||||
if (component.star == nullptr)
|
||||
{
|
||||
cout << "Nonexistent HIP catalog number for component.\n";
|
||||
return false;
|
||||
|
@ -912,19 +881,17 @@ bool ReadComponentRecord(istream& in)
|
|||
|
||||
void BuildMultistarSystemCatalog()
|
||||
{
|
||||
for (vector<HipparcosStar>::iterator iter = stars.begin();
|
||||
iter != stars.end(); iter++)
|
||||
for (const auto& star : stars)
|
||||
{
|
||||
if (iter->CCDMIdentifier != NullCCDMIdentifier)
|
||||
if (star.CCDMIdentifier != NullCCDMIdentifier)
|
||||
{
|
||||
MultistarSystemCatalog::iterator it =
|
||||
starSystems.find(iter->CCDMIdentifier);
|
||||
auto it = starSystems.find(star.CCDMIdentifier);
|
||||
if (it == starSystems.end())
|
||||
{
|
||||
MultistarSystem* multiSystem = new MultistarSystem();
|
||||
multiSystem->nStars = 1;
|
||||
multiSystem->stars[0] = &*iter;
|
||||
starSystems.insert(MultistarSystemCatalog::value_type(iter->CCDMIdentifier, multiSystem));
|
||||
multiSystem->stars[0] = ☆
|
||||
starSystems.insert(MultistarSystemCatalog::value_type(star.CCDMIdentifier, multiSystem));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -935,7 +902,7 @@ void BuildMultistarSystemCatalog()
|
|||
}
|
||||
else
|
||||
{
|
||||
multiSystem->stars[multiSystem->nStars] = &*iter;
|
||||
multiSystem->stars[multiSystem->nStars] = ☆
|
||||
multiSystem->nStars++;
|
||||
}
|
||||
}
|
||||
|
@ -946,10 +913,9 @@ void BuildMultistarSystemCatalog()
|
|||
|
||||
void ConstrainComponentParallaxes()
|
||||
{
|
||||
for (MultistarSystemCatalog::iterator iter = starSystems.begin();
|
||||
iter != starSystems.end(); iter++)
|
||||
for (const auto& ss : starSystems)
|
||||
{
|
||||
MultistarSystem* multiSystem = iter->second;
|
||||
MultistarSystem* multiSystem = ss.second;
|
||||
if (multiSystem->nStars > 1)
|
||||
{
|
||||
for (int i = 1; i < multiSystem->nStars; i++)
|
||||
|
@ -972,14 +938,13 @@ void ConstrainComponentParallaxes()
|
|||
|
||||
void CorrectErrors()
|
||||
{
|
||||
for (vector<HipparcosStar>::iterator iter = stars.begin();
|
||||
iter != stars.end(); iter++)
|
||||
for (auto& star : stars)
|
||||
{
|
||||
// Fix the spectral class of Capella, listed for some reason
|
||||
// as M1 in the database.
|
||||
if (iter->HDCatalogNumber == 34029)
|
||||
if (star.HDCatalogNumber == 34029)
|
||||
{
|
||||
iter->stellarClass = StellarClass(StellarClass::NormalStar,
|
||||
star.stellarClass = StellarClass(StellarClass::NormalStar,
|
||||
StellarClass::Spectral_G, 0,
|
||||
StellarClass::Lum_III);
|
||||
}
|
||||
|
@ -991,35 +956,34 @@ void CorrectErrors()
|
|||
// of stars in the primary database into the companions vector.
|
||||
void CreateCompanionList()
|
||||
{
|
||||
for (vector<HipparcosComponent>::iterator iter = components.begin();
|
||||
iter != components.end(); iter++)
|
||||
for (const auto& comp : components)
|
||||
{
|
||||
// Don't insert the reference component, as this star should already
|
||||
// be in the primary database.
|
||||
if (iter->componentID != iter->refComponentID)
|
||||
if (comp.componentID != comp.refComponentID)
|
||||
{
|
||||
int componentNumber = iter->componentID - 'A';
|
||||
int componentNumber = comp.componentID - 'A';
|
||||
if (componentNumber > 0 && componentNumber < 8)
|
||||
{
|
||||
HipparcosStar star;
|
||||
|
||||
star.HDCatalogNumber = NullCatalogNumber;
|
||||
star.HIPCatalogNumber = iter->star->HIPCatalogNumber |
|
||||
star.HIPCatalogNumber = comp.star->HIPCatalogNumber |
|
||||
(componentNumber << 25);
|
||||
|
||||
star.ascension = iter->ascension;
|
||||
star.declination = iter->declination;
|
||||
star.parallax = iter->star->parallax;
|
||||
star.appMag = iter->appMag;
|
||||
if (iter->hasBV)
|
||||
star.stellarClass = guessSpectralType(iter->bMag - iter->vMag, 0.0f);
|
||||
star.ascension = comp.ascension;
|
||||
star.declination = comp.declination;
|
||||
star.parallax = comp.star->parallax;
|
||||
star.appMag = comp.appMag;
|
||||
if (comp.hasBV)
|
||||
star.stellarClass = guessSpectralType(comp.bMag - comp.vMag, 0.0f);
|
||||
else
|
||||
star.stellarClass = StellarClass(StellarClass::NormalStar,
|
||||
StellarClass::Spectral_Unknown,
|
||||
0, StellarClass::Lum_V);
|
||||
|
||||
star.CCDMIdentifier = iter->star->CCDMIdentifier;
|
||||
star.parallaxError = iter->star->parallaxError;
|
||||
star.CCDMIdentifier = comp.star->CCDMIdentifier;
|
||||
star.parallaxError = comp.star->parallaxError;
|
||||
|
||||
companions.insert(companions.end(), star);
|
||||
}
|
||||
|
@ -1031,16 +995,15 @@ void CreateCompanionList()
|
|||
void ShowStarsWithComponents()
|
||||
{
|
||||
cout << "\nStars with >2 components\n";
|
||||
for (vector<HipparcosStar>::iterator iter = stars.begin();
|
||||
iter != stars.end(); iter++)
|
||||
for (auto& star :stars)
|
||||
{
|
||||
if (iter->nComponents > 2)
|
||||
if (star.nComponents > 2)
|
||||
{
|
||||
cout << (int) iter->nComponents << ": ";
|
||||
if (iter->HDCatalogNumber != NullCatalogNumber)
|
||||
cout << "HD " << iter->HDCatalogNumber;
|
||||
cout << (int) star.nComponents << ": ";
|
||||
if (star.HDCatalogNumber != NullCatalogNumber)
|
||||
cout << "HD " << star.HDCatalogNumber;
|
||||
else
|
||||
cout << "HIP " << iter->HIPCatalogNumber;
|
||||
cout << "HIP " << star.HIPCatalogNumber;
|
||||
cout << '\n';
|
||||
}
|
||||
}
|
||||
|
@ -1049,7 +1012,7 @@ void ShowStarsWithComponents()
|
|||
|
||||
void CompareTycho()
|
||||
{
|
||||
ifstream tycDatabase(TychoDatabaseFile.c_str(), ios::in | ios::binary);
|
||||
ifstream tycDatabase(TychoDatabaseFile, ios::in | ios::binary);
|
||||
if (!tycDatabase.is_open())
|
||||
{
|
||||
cout << "Error opening " << TychoDatabaseFile << '\n';
|
||||
|
@ -1124,7 +1087,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
// Read star records from the primary HIPPARCOS catalog
|
||||
{
|
||||
ifstream mainDatabase(MainDatabaseFile.c_str(), ios::in | ios::binary);
|
||||
ifstream mainDatabase(MainDatabaseFile, ios::in | ios::binary);
|
||||
if (!mainDatabase.is_open())
|
||||
{
|
||||
cout << "Error opening " << MainDatabaseFile << '\n';
|
||||
|
@ -1159,10 +1122,9 @@ int main(int argc, char* argv[])
|
|||
cout << "Sorting stars...\n";
|
||||
{
|
||||
starIndex.reserve(stars.size());
|
||||
for (vector<HipparcosStar>::iterator iter = stars.begin();
|
||||
iter != stars.end(); iter++)
|
||||
for (const auto& star : stars)
|
||||
{
|
||||
starIndex.insert(starIndex.end(), &*iter);
|
||||
starIndex.insert(starIndex.end(), &star);
|
||||
}
|
||||
|
||||
HIPCatalogComparePredicate pred;
|
||||
|
@ -1176,7 +1138,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
// Read component records
|
||||
{
|
||||
ifstream componentDatabase(ComponentDatabaseFile.c_str(),
|
||||
ifstream componentDatabase(ComponentDatabaseFile,
|
||||
ios::in | ios::binary);
|
||||
if (!componentDatabase.is_open())
|
||||
{
|
||||
|
@ -1271,11 +1233,10 @@ int main(int argc, char* argv[])
|
|||
n_drop=0;
|
||||
n_dub=0;
|
||||
{
|
||||
vector<HipparcosStar>::iterator iter;
|
||||
for (iter = stars.begin(); iter != stars.end(); iter++)
|
||||
iter->analyze();
|
||||
for (iter = companions.begin(); iter != companions.end(); iter++)
|
||||
iter->analyze();
|
||||
for (auto& star : stars)
|
||||
star.analyze();
|
||||
for (auto& comp : companions)
|
||||
comp.analyze();
|
||||
binwrite(out, stars.size() + companions.size() - n_drop);
|
||||
float av_r,av_d; // average Right Ascension/Declination
|
||||
av_r=s_er/((float)n_er);
|
||||
|
@ -1285,10 +1246,10 @@ int main(int argc, char* argv[])
|
|||
cout << "RA Error average: " << av_r << " with Standard Error: " << sqrt((s_erq+(square(s_er)/n_er) - (2*av_r*s_er))/(n_er-1)) << " .\n";
|
||||
cout << "DE Error average: " << av_d << " with Standard Error: " << sqrt((s_edq+(square(s_ed)/n_ed) - (2*av_d*s_ed))/(n_ed-1)) << " .\n";
|
||||
}
|
||||
for (iter = stars.begin(); iter != stars.end(); iter++)
|
||||
iter->write(out);
|
||||
for (iter = companions.begin(); iter != companions.end(); iter++)
|
||||
iter->write(out);
|
||||
for (auto& star : stars)
|
||||
star.write(out);
|
||||
for (auto& comp : companions)
|
||||
comp.write(out);
|
||||
}
|
||||
cout << "Stars processed: " << stars.size() + companions.size() << " Number dropped: " << n_drop << " number dubious: " << n_dub << " .\n";
|
||||
|
||||
|
@ -1305,22 +1266,21 @@ int main(int argc, char* argv[])
|
|||
|
||||
{
|
||||
int nHD = 0;
|
||||
vector<HipparcosStar>::iterator iter;
|
||||
for (iter = stars.begin(); iter != stars.end(); iter++)
|
||||
for (const auto& star: stars)
|
||||
{
|
||||
if (iter->HDCatalogNumber != NullCatalogNumber)
|
||||
if (star.HDCatalogNumber != NullCatalogNumber)
|
||||
nHD++;
|
||||
}
|
||||
binwrite(hdout, nHD);
|
||||
|
||||
cout << nHD << " stars have HD numbers.\n";
|
||||
|
||||
for (iter = stars.begin(); iter != stars.end(); iter++)
|
||||
for (const auto& star: stars)
|
||||
{
|
||||
if (iter->HDCatalogNumber != NullCatalogNumber)
|
||||
if (star.HDCatalogNumber != NullCatalogNumber)
|
||||
{
|
||||
binwrite(hdout, iter->HDCatalogNumber);
|
||||
binwrite(hdout, iter->HIPCatalogNumber);
|
||||
binwrite(hdout, star.HDCatalogNumber);
|
||||
binwrite(hdout, star.HIPCatalogNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include "3dsmodel.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace Eigen;
|
||||
using namespace std;
|
||||
|
||||
|
@ -23,15 +25,6 @@ M3DColor::M3DColor(float _red, float _green, float _blue) :
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
M3DMaterial::M3DMaterial() :
|
||||
ambient(0, 0, 0),
|
||||
diffuse(0, 0, 0),
|
||||
specular(0, 0, 0),
|
||||
shininess(1.0f)
|
||||
{
|
||||
}
|
||||
|
||||
string M3DMaterial::getName() const
|
||||
{
|
||||
return name;
|
||||
|
@ -39,7 +32,7 @@ string M3DMaterial::getName() const
|
|||
|
||||
void M3DMaterial::setName(string _name)
|
||||
{
|
||||
name = _name;
|
||||
name = std::move(_name);
|
||||
}
|
||||
|
||||
M3DColor M3DMaterial::getDiffuseColor() const
|
||||
|
@ -108,10 +101,6 @@ M3DTriangleMesh::M3DTriangleMesh()
|
|||
matrix = Matrix4f::Identity();
|
||||
}
|
||||
|
||||
M3DTriangleMesh::~M3DTriangleMesh()
|
||||
{
|
||||
}
|
||||
|
||||
Matrix4f M3DTriangleMesh::getMatrix() const
|
||||
{
|
||||
return matrix;
|
||||
|
@ -174,10 +163,7 @@ void M3DTriangleMesh::addFace(uint16 v0, uint16 v1, uint16 v2)
|
|||
|
||||
uint32 M3DTriangleMesh::getSmoothingGroups(uint16 face) const
|
||||
{
|
||||
if (face < smoothingGroups.size())
|
||||
return smoothingGroups[face];
|
||||
else
|
||||
return 0;
|
||||
return face < smoothingGroups.size() ? smoothingGroups[face] : 0;
|
||||
}
|
||||
|
||||
void M3DTriangleMesh::addSmoothingGroups(uint32 smGroups)
|
||||
|
@ -206,24 +192,15 @@ uint32 M3DTriangleMesh::getMeshMaterialGroupCount() const
|
|||
}
|
||||
|
||||
|
||||
|
||||
M3DModel::M3DModel()
|
||||
{
|
||||
}
|
||||
|
||||
M3DModel::~M3DModel()
|
||||
{
|
||||
for (unsigned int i = 0; i < triMeshes.size(); i++)
|
||||
if (triMeshes[i] != NULL)
|
||||
delete triMeshes[i];
|
||||
for (auto triMesh : triMeshes)
|
||||
delete triMesh;
|
||||
}
|
||||
|
||||
M3DTriangleMesh* M3DModel::getTriMesh(uint32 n)
|
||||
{
|
||||
if (n < triMeshes.size())
|
||||
return triMeshes[n];
|
||||
else
|
||||
return NULL;
|
||||
return n < triMeshes.size() ? triMeshes[n] : nullptr;
|
||||
}
|
||||
|
||||
uint32 M3DModel::getTriMeshCount()
|
||||
|
@ -236,7 +213,7 @@ void M3DModel::addTriMesh(M3DTriangleMesh* triMesh)
|
|||
triMeshes.insert(triMeshes.end(), triMesh);
|
||||
}
|
||||
|
||||
void M3DModel::setName(const string _name)
|
||||
void M3DModel::setName(const string& _name)
|
||||
{
|
||||
name = _name;
|
||||
}
|
||||
|
@ -247,27 +224,17 @@ const string M3DModel::getName() const
|
|||
}
|
||||
|
||||
|
||||
M3DScene::M3DScene()
|
||||
{
|
||||
}
|
||||
|
||||
M3DScene::~M3DScene()
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < models.size(); i++)
|
||||
if (models[i] != NULL)
|
||||
delete models[i];
|
||||
for (i = 0; i < materials.size(); i++)
|
||||
if (materials[i] != NULL)
|
||||
delete materials[i];
|
||||
for (auto model : models)
|
||||
delete model;
|
||||
for (auto material : materials)
|
||||
delete material;
|
||||
}
|
||||
|
||||
M3DModel* M3DScene::getModel(uint32 n) const
|
||||
{
|
||||
if (n < models.size())
|
||||
return models[n];
|
||||
else
|
||||
return NULL;
|
||||
return n < models.size() ? models[n] : nullptr;
|
||||
}
|
||||
|
||||
uint32 M3DScene::getModelCount() const
|
||||
|
@ -282,10 +249,7 @@ void M3DScene::addModel(M3DModel* model)
|
|||
|
||||
M3DMaterial* M3DScene::getMaterial(uint32 n) const
|
||||
{
|
||||
if (n < materials.size())
|
||||
return materials[n];
|
||||
else
|
||||
return NULL;
|
||||
return n < materials.size() ? materials[n] : nullptr;
|
||||
}
|
||||
|
||||
uint32 M3DScene::getMaterialCount() const
|
||||
|
|
|
@ -29,7 +29,7 @@ class M3DColor
|
|||
class M3DMaterial
|
||||
{
|
||||
public:
|
||||
M3DMaterial();
|
||||
M3DMaterial() = default;
|
||||
|
||||
std::string getName() const;
|
||||
void setName(std::string);
|
||||
|
@ -49,11 +49,11 @@ class M3DMaterial
|
|||
private:
|
||||
std::string name;
|
||||
std::string texmap;
|
||||
M3DColor ambient;
|
||||
M3DColor diffuse;
|
||||
M3DColor specular;
|
||||
float shininess;
|
||||
float opacity;
|
||||
M3DColor ambient{ 0, 0, 0 };
|
||||
M3DColor diffuse{ 0, 0, 0 };
|
||||
M3DColor specular{ 0, 0, 0 };
|
||||
float shininess{ 1.0f };
|
||||
float opacity{};
|
||||
};
|
||||
|
||||
|
||||
|
@ -71,7 +71,7 @@ class M3DTriangleMesh
|
|||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||
|
||||
M3DTriangleMesh();
|
||||
~M3DTriangleMesh();
|
||||
~M3DTriangleMesh() = default;
|
||||
|
||||
Eigen::Matrix4f getMatrix() const;
|
||||
void setMatrix(const Eigen::Matrix4f&);
|
||||
|
@ -109,13 +109,13 @@ class M3DTriangleMesh
|
|||
class M3DModel
|
||||
{
|
||||
public:
|
||||
M3DModel();
|
||||
M3DModel() = default;
|
||||
~M3DModel();
|
||||
|
||||
M3DTriangleMesh* getTriMesh(uint32);
|
||||
uint32 getTriMeshCount();
|
||||
void addTriMesh(M3DTriangleMesh*);
|
||||
void setName(const std::string);
|
||||
void setName(const std::string&);
|
||||
const std::string getName() const;
|
||||
|
||||
private:
|
||||
|
@ -127,7 +127,7 @@ class M3DModel
|
|||
class M3DScene
|
||||
{
|
||||
public:
|
||||
M3DScene();
|
||||
M3DScene() = default;
|
||||
~M3DScene();
|
||||
|
||||
M3DModel* getModel(uint32) const;
|
||||
|
|
|
@ -18,10 +18,7 @@
|
|||
using namespace Eigen;
|
||||
using namespace std;
|
||||
|
||||
typedef bool (*ProcessChunkFunc)(ifstream& in,
|
||||
unsigned short chunkType,
|
||||
int contentSize,
|
||||
void*);
|
||||
using ProcessChunkFunc = bool (*)(ifstream &, unsigned short, int, void *);
|
||||
|
||||
static int read3DSChunk(ifstream& in,
|
||||
ProcessChunkFunc chunkFunc,
|
||||
|
@ -119,7 +116,7 @@ void indent()
|
|||
void logChunk(uint16 /*chunkType*/ /*, int chunkSize*/)
|
||||
{
|
||||
#if 0
|
||||
const char* name = NULL;
|
||||
const char* name = nullptr;
|
||||
|
||||
switch (chunkType)
|
||||
{
|
||||
|
@ -197,7 +194,7 @@ void logChunk(uint16 /*chunkType*/ /*, int chunkSize*/)
|
|||
|
||||
indent();
|
||||
|
||||
if (name == NULL)
|
||||
if (name == nullptr)
|
||||
{
|
||||
cout << "Chunk ID " << setw(4) << hex << setfill('0') << chunkType;
|
||||
cout << setw(0) << dec << ", size = " << chunkSize << '\n';
|
||||
|
@ -252,13 +249,13 @@ int read3DSChunks(ifstream& in,
|
|||
|
||||
M3DColor readColor(ifstream& in/*, int nBytes*/)
|
||||
{
|
||||
unsigned char r = (unsigned char) readChar(in);
|
||||
unsigned char g = (unsigned char) readChar(in);
|
||||
unsigned char b = (unsigned char) readChar(in);
|
||||
auto r = (unsigned char) readChar(in);
|
||||
auto g = (unsigned char) readChar(in);
|
||||
auto b = (unsigned char) readChar(in);
|
||||
|
||||
return M3DColor((float) r / 255.0f,
|
||||
(float) g / 255.0f,
|
||||
(float) b / 255.0f);
|
||||
return {(float) r / 255.0f,
|
||||
(float) g / 255.0f,
|
||||
(float) b / 255.0f};
|
||||
}
|
||||
|
||||
|
||||
|
@ -268,9 +265,9 @@ M3DColor readFloatColor(ifstream& in/*, int nBytes*/)
|
|||
float g = readFloat(in);
|
||||
float b = readFloat(in);
|
||||
|
||||
return M3DColor((float) r / 255.0f,
|
||||
(float) g / 255.0f,
|
||||
(float) b / 255.0f);
|
||||
return {(float) r / 255.0f,
|
||||
(float) g / 255.0f,
|
||||
(float) b / 255.0f};
|
||||
}
|
||||
|
||||
|
||||
|
@ -353,14 +350,17 @@ bool processFaceArrayChunk(ifstream& in,
|
|||
int /*contentSize*/,
|
||||
void* obj)
|
||||
{
|
||||
M3DTriangleMesh* triMesh = (M3DTriangleMesh*) obj;
|
||||
auto* triMesh = (M3DTriangleMesh*) obj;
|
||||
uint16 nFaces;
|
||||
M3DMeshMaterialGroup* matGroup;
|
||||
|
||||
if (chunkType == M3DCHUNK_MESH_MATERIAL_GROUP)
|
||||
switch (chunkType)
|
||||
{
|
||||
M3DMeshMaterialGroup* matGroup = new M3DMeshMaterialGroup();
|
||||
case M3DCHUNK_MESH_MATERIAL_GROUP:
|
||||
matGroup = new M3DMeshMaterialGroup();
|
||||
|
||||
matGroup->materialName = readString(in);
|
||||
uint16 nFaces = readUshort(in);
|
||||
nFaces = readUshort(in);
|
||||
|
||||
for (uint16 i = 0; i < nFaces; i++)
|
||||
{
|
||||
|
@ -371,10 +371,8 @@ bool processFaceArrayChunk(ifstream& in,
|
|||
triMesh->addMeshMaterialGroup(matGroup);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (chunkType == M3DCHUNK_MESH_SMOOTH_GROUP)
|
||||
{
|
||||
uint16 nFaces = triMesh->getFaceCount();
|
||||
case M3DCHUNK_MESH_SMOOTH_GROUP:
|
||||
nFaces = triMesh->getFaceCount();
|
||||
|
||||
for (uint16 i = 0; i < nFaces; i++)
|
||||
{
|
||||
|
@ -383,10 +381,7 @@ bool processFaceArrayChunk(ifstream& in,
|
|||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -419,32 +414,25 @@ bool processTriMeshChunk(ifstream& in,
|
|||
int contentSize,
|
||||
void* obj)
|
||||
{
|
||||
M3DTriangleMesh* triMesh = (M3DTriangleMesh*) obj;
|
||||
auto* triMesh = (M3DTriangleMesh*) obj;
|
||||
|
||||
if (chunkType == M3DCHUNK_POINT_ARRAY)
|
||||
switch (chunkType)
|
||||
{
|
||||
case M3DCHUNK_POINT_ARRAY:
|
||||
readPointArray(in, triMesh);
|
||||
return true;
|
||||
}
|
||||
else if (chunkType == M3DCHUNK_MESH_TEXTURE_COORDS)
|
||||
{
|
||||
case M3DCHUNK_MESH_TEXTURE_COORDS:
|
||||
readTextureCoordArray(in, triMesh);
|
||||
return true;
|
||||
}
|
||||
else if (chunkType == M3DCHUNK_FACE_ARRAY)
|
||||
{
|
||||
case M3DCHUNK_FACE_ARRAY:
|
||||
readFaceArray(in, triMesh, contentSize);
|
||||
return true;
|
||||
}
|
||||
else if (chunkType == M3DCHUNK_MESH_MATRIX)
|
||||
{
|
||||
case M3DCHUNK_MESH_MATRIX:
|
||||
triMesh->setMatrix(readMeshMatrix(in/*, contentSize*/));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -453,19 +441,17 @@ bool processModelChunk(ifstream& in,
|
|||
int contentSize,
|
||||
void* obj)
|
||||
{
|
||||
M3DModel* model = (M3DModel*) obj;
|
||||
auto* model = (M3DModel*) obj;
|
||||
|
||||
if (chunkType == M3DCHUNK_TRIANGLE_MESH)
|
||||
{
|
||||
M3DTriangleMesh* triMesh = new M3DTriangleMesh();
|
||||
auto* triMesh = new M3DTriangleMesh();
|
||||
read3DSChunks(in, contentSize, processTriMeshChunk, (void*) triMesh);
|
||||
model->addTriMesh(triMesh);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -474,22 +460,19 @@ bool processColorChunk(ifstream& in,
|
|||
int /*contentSize*/,
|
||||
void* obj)
|
||||
{
|
||||
M3DColor* color = (M3DColor*) obj;
|
||||
auto* color = (M3DColor*) obj;
|
||||
|
||||
if (chunkType == M3DCHUNK_COLOR_24)
|
||||
switch (chunkType)
|
||||
{
|
||||
case M3DCHUNK_COLOR_24:
|
||||
*color = readColor(in/*, contentSize*/);
|
||||
return true;
|
||||
}
|
||||
else if (chunkType == (M3DCHUNK_COLOR_FLOAT))
|
||||
{
|
||||
case M3DCHUNK_COLOR_FLOAT:
|
||||
*color = readFloatColor(in/*, contentSize*/);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -498,22 +481,19 @@ static bool processPercentageChunk(ifstream& in,
|
|||
int /*contentSize*/,
|
||||
void* obj)
|
||||
{
|
||||
float* percent = (float*) obj;
|
||||
auto* percent = (float*) obj;
|
||||
|
||||
if (chunkType == M3DCHUNK_INT_PERCENTAGE)
|
||||
switch (chunkType)
|
||||
{
|
||||
case M3DCHUNK_INT_PERCENTAGE:
|
||||
*percent = readShort(in);
|
||||
return true;
|
||||
}
|
||||
else if (chunkType == M3DCHUNK_FLOAT_PERCENTAGE)
|
||||
{
|
||||
case M3DCHUNK_FLOAT_PERCENTAGE:
|
||||
*percent = readFloat(in);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -522,7 +502,7 @@ static bool processTexmapChunk(ifstream& in,
|
|||
int /*contentSize*/,
|
||||
void* obj)
|
||||
{
|
||||
M3DMaterial* material = (M3DMaterial*) obj;
|
||||
auto* material = (M3DMaterial*) obj;
|
||||
|
||||
if (chunkType == M3DCHUNK_MATERIAL_MAPNAME)
|
||||
{
|
||||
|
@ -530,10 +510,8 @@ static bool processTexmapChunk(ifstream& in,
|
|||
material->setTextureMap(name);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -542,61 +520,43 @@ bool processMaterialChunk(ifstream& in,
|
|||
int contentSize,
|
||||
void* obj)
|
||||
{
|
||||
M3DMaterial* material = (M3DMaterial*) obj;
|
||||
auto* material = (M3DMaterial*) obj;
|
||||
string name;
|
||||
M3DColor color;
|
||||
float t;
|
||||
|
||||
if (chunkType == M3DCHUNK_MATERIAL_NAME)
|
||||
switch (chunkType)
|
||||
{
|
||||
string name = readString(in);
|
||||
case M3DCHUNK_MATERIAL_NAME:
|
||||
name = readString(in);
|
||||
material->setName(name);
|
||||
return true;
|
||||
}
|
||||
else if (chunkType == M3DCHUNK_MATERIAL_AMBIENT)
|
||||
{
|
||||
M3DColor ambient;
|
||||
read3DSChunks(in, contentSize, processColorChunk, (void*) &ambient);
|
||||
material->setAmbientColor(ambient);
|
||||
case M3DCHUNK_MATERIAL_AMBIENT:
|
||||
read3DSChunks(in, contentSize, processColorChunk, (void*) &color);
|
||||
material->setAmbientColor(color);
|
||||
return true;
|
||||
}
|
||||
else if (chunkType == M3DCHUNK_MATERIAL_DIFFUSE)
|
||||
{
|
||||
M3DColor diffuse;
|
||||
read3DSChunks(in, contentSize, processColorChunk, (void*) &diffuse);
|
||||
material->setDiffuseColor(diffuse);
|
||||
case M3DCHUNK_MATERIAL_DIFFUSE:
|
||||
read3DSChunks(in, contentSize, processColorChunk, (void*) &color);
|
||||
material->setDiffuseColor(color);
|
||||
return true;
|
||||
}
|
||||
else if (chunkType == M3DCHUNK_MATERIAL_SPECULAR)
|
||||
{
|
||||
M3DColor specular;
|
||||
read3DSChunks(in, contentSize, processColorChunk, (void*) &specular);
|
||||
material->setSpecularColor(specular);
|
||||
case M3DCHUNK_MATERIAL_SPECULAR:
|
||||
read3DSChunks(in, contentSize, processColorChunk, (void*) &color);
|
||||
material->setSpecularColor(color);
|
||||
return true;
|
||||
}
|
||||
else if (chunkType == M3DCHUNK_MATERIAL_SHININESS)
|
||||
{
|
||||
float shininess;
|
||||
read3DSChunks(in, contentSize, processPercentageChunk,
|
||||
(void*) &shininess);
|
||||
material->setShininess(shininess);
|
||||
case M3DCHUNK_MATERIAL_SHININESS:
|
||||
read3DSChunks(in, contentSize, processPercentageChunk, (void*) &t);
|
||||
material->setShininess(t);
|
||||
return true;
|
||||
}
|
||||
else if (chunkType == M3DCHUNK_MATERIAL_TRANSPARENCY)
|
||||
{
|
||||
float transparency;
|
||||
read3DSChunks(in, contentSize, processPercentageChunk,
|
||||
(void*) &transparency);
|
||||
material->setOpacity(1.0f - transparency / 100.0f);
|
||||
case M3DCHUNK_MATERIAL_TRANSPARENCY:
|
||||
read3DSChunks(in, contentSize, processPercentageChunk, (void*) &t);
|
||||
material->setOpacity(1.0f - t / 100.0f);
|
||||
return true;
|
||||
}
|
||||
|
||||
else if (chunkType == M3DCHUNK_MATERIAL_TEXMAP)
|
||||
{
|
||||
case M3DCHUNK_MATERIAL_TEXMAP:
|
||||
read3DSChunks(in, contentSize, processTexmapChunk, (void*) material);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -605,13 +565,17 @@ bool processSceneChunk(ifstream& in,
|
|||
int contentSize,
|
||||
void* obj)
|
||||
{
|
||||
M3DScene* scene = (M3DScene*) obj;
|
||||
auto* scene = (M3DScene*) obj;
|
||||
M3DModel* model;
|
||||
M3DMaterial* material;
|
||||
M3DColor color;
|
||||
string name;
|
||||
|
||||
if (chunkType == M3DCHUNK_NAMED_OBJECT)
|
||||
switch (chunkType)
|
||||
{
|
||||
string name = readString(in);
|
||||
|
||||
M3DModel* model = new M3DModel();
|
||||
case M3DCHUNK_NAMED_OBJECT:
|
||||
name = readString(in);
|
||||
model = new M3DModel();
|
||||
model->setName(name);
|
||||
// indent(); cout << " [" << name << "]\n";
|
||||
read3DSChunks(in,
|
||||
|
@ -621,10 +585,8 @@ bool processSceneChunk(ifstream& in,
|
|||
scene->addModel(model);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (chunkType == M3DCHUNK_MATERIAL_ENTRY)
|
||||
{
|
||||
M3DMaterial* material = new M3DMaterial();
|
||||
case M3DCHUNK_MATERIAL_ENTRY:
|
||||
material = new M3DMaterial();
|
||||
read3DSChunks(in,
|
||||
contentSize,
|
||||
processMaterialChunk,
|
||||
|
@ -632,16 +594,11 @@ bool processSceneChunk(ifstream& in,
|
|||
scene->addMaterial(material);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (chunkType == M3DCHUNK_BACKGROUND_COLOR)
|
||||
{
|
||||
M3DColor color;
|
||||
case M3DCHUNK_BACKGROUND_COLOR:
|
||||
read3DSChunks(in, contentSize, processColorChunk, (void*) &color);
|
||||
scene->setBackgroundColor(color);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -652,17 +609,15 @@ bool processTopLevelChunk(ifstream& in,
|
|||
int contentSize,
|
||||
void* obj)
|
||||
{
|
||||
M3DScene* scene = (M3DScene*) obj;
|
||||
auto* scene = (M3DScene*) obj;
|
||||
|
||||
if (chunkType == M3DCHUNK_MESHDATA)
|
||||
{
|
||||
read3DSChunks(in, contentSize, processSceneChunk, (void*) scene);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -672,19 +627,19 @@ M3DScene* Read3DSFile(ifstream& in)
|
|||
if (chunkType != M3DCHUNK_MAGIC)
|
||||
{
|
||||
DPRINTF(0, "Read3DSFile: Wrong magic number in header\n");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32 chunkSize = readInt(in);
|
||||
if (in.bad())
|
||||
{
|
||||
DPRINTF(0, "Read3DSFile: Error reading 3DS file.\n");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DPRINTF(1, "3DS file, %d bytes\n", chunkSize);
|
||||
|
||||
M3DScene* scene = new M3DScene();
|
||||
auto* scene = new M3DScene();
|
||||
int contentSize = chunkSize - 6;
|
||||
|
||||
read3DSChunks(in, contentSize, processTopLevelChunk, (void*) scene);
|
||||
|
@ -695,18 +650,16 @@ M3DScene* Read3DSFile(ifstream& in)
|
|||
|
||||
M3DScene* Read3DSFile(const string& filename)
|
||||
{
|
||||
ifstream in(filename.c_str(), ios::in | ios::binary);
|
||||
ifstream in(filename, ios::in | ios::binary);
|
||||
if (!in.good())
|
||||
{
|
||||
DPRINTF(0, "Read3DSFile: Error opening %s\n", filename.c_str());
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
M3DScene* scene = Read3DSFile(in);
|
||||
in.close();
|
||||
return scene;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
M3DScene* scene = Read3DSFile(in);
|
||||
in.close();
|
||||
return scene;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ public:
|
|||
char* data;
|
||||
kern_return_t err = vm_allocate((vm_map_t) mach_task_self(), (vm_address_t*) &data, size, TRUE);
|
||||
|
||||
return (err == KERN_SUCCESS) ? new MemoryBuffer(data, size) : NULL;
|
||||
return (err == KERN_SUCCESS) ? new MemoryBuffer(data, size) : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -151,7 +151,7 @@ public:
|
|||
MemoryBuffer* data_buffer;
|
||||
unsigned long data_size;
|
||||
|
||||
Datafile() : ref_count(1), file(NULL), data_buffer(NULL), data_size(0)
|
||||
Datafile() : ref_count(1), file(nullptr), data_buffer(nullptr), data_size(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ public:
|
|||
|
||||
int Read()
|
||||
{
|
||||
if ((file == NULL) || (data_buffer == NULL) || (data_size == 0)) {
|
||||
if ((file == nullptr) || (data_buffer == nullptr) || (data_size == 0)) {
|
||||
DPRINTF(0,"Datafile::Read() - No file open, file of zero size, or no valid MemoryBuffer\n");
|
||||
Reset();
|
||||
return 0;
|
||||
|
@ -215,7 +215,7 @@ public:
|
|||
{
|
||||
if (file) {
|
||||
fclose(file);
|
||||
file = NULL;
|
||||
file = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ public:
|
|||
Close();
|
||||
if (data_buffer) {
|
||||
data_buffer->Release();
|
||||
data_buffer = NULL;
|
||||
data_buffer = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -240,9 +240,9 @@ class CGBuffer
|
|||
void Init()
|
||||
{
|
||||
ref_count = 1;
|
||||
buffer = NULL;
|
||||
image_ref = NULL;
|
||||
context_ref = NULL;
|
||||
buffer = nullptr;
|
||||
image_ref = nullptr;
|
||||
context_ref = nullptr;
|
||||
image_finished = false;
|
||||
}
|
||||
|
||||
|
@ -251,13 +251,13 @@ class CGBuffer
|
|||
if (context_ref)
|
||||
{
|
||||
CGContextRelease(context_ref);
|
||||
context_ref = NULL;
|
||||
context_ref = nullptr;
|
||||
}
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
buffer->Release();
|
||||
buffer = NULL;
|
||||
buffer = nullptr;
|
||||
}
|
||||
|
||||
size_t buffer_rowbytes = (size_t)(image_size.width * ((image_depth == 8) ? 1 : 4)); //CGImageGetBytesPerRow(image_ref);
|
||||
|
@ -287,7 +287,7 @@ class CGBuffer
|
|||
}
|
||||
|
||||
CGColorSpaceRelease(colorspace_ref);
|
||||
colorspace_ref = NULL;
|
||||
colorspace_ref = nullptr;
|
||||
|
||||
return !!context_ref;
|
||||
}
|
||||
|
@ -343,15 +343,15 @@ public:
|
|||
|
||||
file.Close();
|
||||
|
||||
CGDataProviderRef src_provider_ref = CGDataProviderCreateWithData(this, file.data_buffer->data, file.data_size, NULL);
|
||||
CGDataProviderRef src_provider_ref = CGDataProviderCreateWithData(this, file.data_buffer->data, file.data_size, nullptr);
|
||||
|
||||
if (!src_provider_ref)
|
||||
return false;
|
||||
|
||||
image_ref = CGImageCreateWithJPEGDataProvider(src_provider_ref, NULL, true, kCGRenderingIntentDefault);
|
||||
image_ref = CGImageCreateWithJPEGDataProvider(src_provider_ref, nullptr, true, kCGRenderingIntentDefault);
|
||||
|
||||
CGDataProviderRelease(src_provider_ref);
|
||||
src_provider_ref = NULL;
|
||||
src_provider_ref = nullptr;
|
||||
|
||||
if (!image_ref)
|
||||
return false;
|
||||
|
@ -373,10 +373,10 @@ public:
|
|||
RenderCGImage(CGFrame(image_size));
|
||||
|
||||
CGContextRelease(context_ref);
|
||||
context_ref = NULL;
|
||||
context_ref = nullptr;
|
||||
|
||||
CGImageRelease(image_ref);
|
||||
image_ref = NULL;
|
||||
image_ref = nullptr;
|
||||
|
||||
file.Reset();
|
||||
|
||||
|
@ -388,19 +388,19 @@ public:
|
|||
if (buffer)
|
||||
{
|
||||
buffer->Release();
|
||||
buffer = NULL;
|
||||
buffer = nullptr;
|
||||
}
|
||||
|
||||
if (image_ref)
|
||||
{
|
||||
CGImageRelease(image_ref);
|
||||
image_ref = NULL;
|
||||
image_ref = nullptr;
|
||||
}
|
||||
|
||||
if (context_ref)
|
||||
{
|
||||
CGContextRelease(context_ref);
|
||||
context_ref = NULL;
|
||||
context_ref = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
|
@ -24,18 +24,11 @@ using namespace std;
|
|||
|
||||
|
||||
Asterism::Asterism(string _name) :
|
||||
name(_name),
|
||||
active(true),
|
||||
useOverrideColor(false)
|
||||
name(_name)
|
||||
{
|
||||
i18nName = dgettext("celestia_constellations", _name.c_str());
|
||||
}
|
||||
|
||||
Asterism::~Asterism()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
string Asterism::getName(bool i18n) const
|
||||
{
|
||||
return i18n?i18nName:name;
|
||||
|
@ -113,7 +106,7 @@ bool Asterism::isColorOverridden() const
|
|||
|
||||
AsterismList* ReadAsterismList(istream& in, const StarDatabase& stardb)
|
||||
{
|
||||
AsterismList* asterisms = new AsterismList();
|
||||
auto* asterisms = new AsterismList();
|
||||
Tokenizer tokenizer(&in);
|
||||
Parser parser(&tokenizer);
|
||||
|
||||
|
@ -124,21 +117,21 @@ AsterismList* ReadAsterismList(istream& in, const StarDatabase& stardb)
|
|||
DPRINTF(0, "Error parsing asterism file.\n");
|
||||
for_each(asterisms->begin(), asterisms->end(), deleteFunc<Asterism*>());
|
||||
delete asterisms;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
string name = tokenizer.getStringValue();
|
||||
Asterism* ast = new Asterism(name);
|
||||
|
||||
Value* chainsValue = parser.readValue();
|
||||
if (chainsValue == NULL || chainsValue->getType() != Value::ArrayType)
|
||||
if (chainsValue == nullptr || chainsValue->getType() != Value::ArrayType)
|
||||
{
|
||||
DPRINTF(0, "Error parsing asterism %s\n", name.c_str());
|
||||
for_each(asterisms->begin(), asterisms->end(), deleteFunc<Asterism*>());
|
||||
delete ast;
|
||||
delete asterisms;
|
||||
delete chainsValue;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Array* chains = chainsValue->getArray();
|
||||
|
@ -149,12 +142,12 @@ AsterismList* ReadAsterismList(istream& in, const StarDatabase& stardb)
|
|||
{
|
||||
Array* a = (*chains)[i]->getArray();
|
||||
Asterism::Chain* chain = new Asterism::Chain();
|
||||
for (Array::const_iterator iter = a->begin(); iter != a->end(); iter++)
|
||||
for (const auto i : *a)
|
||||
{
|
||||
if ((*iter)->getType() == Value::StringType)
|
||||
if (i->getType() == Value::StringType)
|
||||
{
|
||||
Star* star = stardb.find((*iter)->getString());
|
||||
if (star != NULL)
|
||||
Star* star = stardb.find(i->getString());
|
||||
if (star != nullptr)
|
||||
chain->push_back(star->getPosition());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class Asterism
|
|||
{
|
||||
public:
|
||||
Asterism(std::string);
|
||||
~Asterism();
|
||||
~Asterism() = default;
|
||||
|
||||
typedef std::vector<Eigen::Vector3f> Chain;
|
||||
|
||||
|
@ -43,8 +43,8 @@ class Asterism
|
|||
std::string i18nName;
|
||||
std::vector<Chain*> chains;
|
||||
|
||||
bool active;
|
||||
bool useOverrideColor;
|
||||
bool active{ true };
|
||||
bool useOverrideColor{ false };
|
||||
Color color;
|
||||
};
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
#include <cmath>
|
||||
#include <iomanip>
|
||||
#include <cstdio>
|
||||
#include <time.h>
|
||||
#include <utility>
|
||||
#include <ctime>
|
||||
#include <celutil/basictypes.h>
|
||||
#include <celmath/mathlib.h>
|
||||
#include "celestia.h"
|
||||
|
@ -300,7 +301,7 @@ void astro::decimalToHourMinSec(double angle, int& hours, int& minutes, double&
|
|||
// Compute the fraction of a sphere which is illuminated and visible
|
||||
// to a viewer. The source of illumination is assumed to be at (0, 0, 0)
|
||||
float astro::sphereIlluminationFraction(Point3d,
|
||||
Point3d)
|
||||
Point3d /*unused*/)
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
|
@ -671,7 +672,7 @@ bool astro::parseDate(const string& s, astro::Date& date)
|
|||
astro::Date
|
||||
astro::Date::systemDate()
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
time_t t = time(nullptr);
|
||||
struct tm *gmt = gmtime(&t);
|
||||
astro::Date d;
|
||||
d.year = gmt->tm_year + 1900;
|
||||
|
@ -685,7 +686,7 @@ astro::Date::systemDate()
|
|||
}
|
||||
|
||||
|
||||
ostream& operator<<(ostream& s, const astro::Date d)
|
||||
ostream& operator<<(ostream& s, const astro::Date& d)
|
||||
{
|
||||
s << d.toCStr();
|
||||
return s;
|
||||
|
@ -710,7 +711,7 @@ astro::TAItoUTC(double tai)
|
|||
dAT = LeapSeconds[i].seconds;
|
||||
break;
|
||||
}
|
||||
else if (tai - secsToDays(LeapSeconds[i - 1].seconds) >= LeapSeconds[i].t)
|
||||
if (tai - secsToDays(LeapSeconds[i - 1].seconds) >= LeapSeconds[i].t)
|
||||
{
|
||||
dAT = LeapSeconds[i].seconds;
|
||||
extraSecs = LeapSeconds[i].seconds - LeapSeconds[i - 1].seconds;
|
||||
|
@ -823,7 +824,7 @@ astro::TDBtoLocal(double tdb)
|
|||
{
|
||||
time_t time = (int) astro::julianDateToSeconds(jdutc - 2440587.5);
|
||||
struct tm *localt = localtime(&time);
|
||||
if (localt != NULL)
|
||||
if (localt != nullptr)
|
||||
{
|
||||
astro::Date d;
|
||||
d.year = localt->tm_year + 1900;
|
||||
|
@ -909,7 +910,7 @@ astro::TAItoJDUTC(double tai)
|
|||
|
||||
|
||||
// Get scale of given length unit in kilometers
|
||||
bool astro::getLengthScale(string unitName, double& scale)
|
||||
bool astro::getLengthScale(const string& unitName, double& scale)
|
||||
{
|
||||
unsigned int nUnits = sizeof(lengthUnits) / sizeof(lengthUnits[0]);
|
||||
bool foundMatch = false;
|
||||
|
@ -928,40 +929,34 @@ bool astro::getLengthScale(string unitName, double& scale)
|
|||
|
||||
|
||||
// Get scale of given time unit in days
|
||||
bool astro::getTimeScale(string unitName, double& scale)
|
||||
bool astro::getTimeScale(const string& unitName, double& scale)
|
||||
{
|
||||
unsigned int nUnits = sizeof(timeUnits) / sizeof(timeUnits[0]);
|
||||
bool foundMatch = false;
|
||||
for(unsigned int i = 0; i < nUnits; i++)
|
||||
for (const auto& timeUnit : timeUnits)
|
||||
{
|
||||
if (timeUnits[i].name == unitName)
|
||||
if (timeUnit.name == unitName)
|
||||
{
|
||||
foundMatch = true;
|
||||
scale = timeUnits[i].conversion;
|
||||
break;
|
||||
scale = timeUnit.conversion;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return foundMatch;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Get scale of given angle unit in degrees
|
||||
bool astro::getAngleScale(string unitName, double& scale)
|
||||
bool astro::getAngleScale(const string& unitName, double& scale)
|
||||
{
|
||||
unsigned int nUnits = sizeof(angleUnits) / sizeof(angleUnits[0]);
|
||||
bool foundMatch = false;
|
||||
for (unsigned int i = 0; i < nUnits; i++)
|
||||
for (const auto& angleUnit : angleUnits)
|
||||
{
|
||||
if (angleUnits[i].name == unitName)
|
||||
if (angleUnit.name == unitName)
|
||||
{
|
||||
foundMatch = true;
|
||||
scale = angleUnits[i].conversion;
|
||||
break;
|
||||
scale = angleUnit.conversion;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return foundMatch;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -969,7 +964,7 @@ bool astro::getAngleScale(string unitName, double& scale)
|
|||
bool astro::isLengthUnit(string unitName)
|
||||
{
|
||||
double dummy;
|
||||
return getLengthScale(unitName, dummy);
|
||||
return getLengthScale(std::move(unitName), dummy);
|
||||
}
|
||||
|
||||
|
||||
|
@ -977,7 +972,7 @@ bool astro::isLengthUnit(string unitName)
|
|||
bool astro::isTimeUnit(string unitName)
|
||||
{
|
||||
double dummy;
|
||||
return getTimeScale(unitName, dummy);
|
||||
return getTimeScale(std::move(unitName), dummy);
|
||||
}
|
||||
|
||||
|
||||
|
@ -985,5 +980,5 @@ bool astro::isTimeUnit(string unitName)
|
|||
bool astro::isAngleUnit(string unitName)
|
||||
{
|
||||
double dummy;
|
||||
return getAngleScale(unitName, dummy);
|
||||
return getAngleScale(std::move(unitName), dummy);
|
||||
}
|
||||
|
|
|
@ -175,9 +175,9 @@ namespace astro
|
|||
bool isLengthUnit(string unitName);
|
||||
bool isTimeUnit(string unitName);
|
||||
bool isAngleUnit(string unitName);
|
||||
bool getLengthScale(string unitName, double& scale);
|
||||
bool getTimeScale(string unitName, double& scale);
|
||||
bool getAngleScale(string unitName, double& scale);
|
||||
bool getLengthScale(const string& unitName, double& scale);
|
||||
bool getTimeScale(const string& unitName, double& scale);
|
||||
bool getAngleScale(const string& unitName, double& scale);
|
||||
|
||||
void decimalToDegMinSec(double angle, int& degrees, int& minutes, double& seconds);
|
||||
double degMinSecToDecimal(int degrees, int minutes, double seconds);
|
||||
|
@ -215,7 +215,7 @@ namespace astro
|
|||
|
||||
// Convert a date structure to a Julian date
|
||||
|
||||
std::ostream& operator<<(std::ostream& s, const astro::Date);
|
||||
std::ostream& operator<<(std::ostream& s, const astro::Date&);
|
||||
|
||||
#endif // _CELENGINE_ASTRO_H_
|
||||
|
||||
|
|
|
@ -379,23 +379,19 @@ Vector3d
|
|||
SunDirectionArrow::getDirection(double tdb) const
|
||||
{
|
||||
const Body* b = &body;
|
||||
Star* sun = NULL;
|
||||
while (b != NULL)
|
||||
Star* sun = nullptr;
|
||||
while (b != nullptr)
|
||||
{
|
||||
Selection center = b->getOrbitFrame(tdb)->getCenter();
|
||||
if (center.star() != NULL)
|
||||
if (center.star() != nullptr)
|
||||
sun = center.star();
|
||||
b = center.body();
|
||||
}
|
||||
|
||||
if (sun != NULL)
|
||||
{
|
||||
if (sun != nullptr)
|
||||
return Selection(sun).getPosition(tdb).offsetFromKm(body.getPosition(tdb));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Vector3d::Zero();
|
||||
}
|
||||
|
||||
return Vector3d::Zero();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,34 +28,8 @@ using namespace std;
|
|||
|
||||
|
||||
Body::Body(PlanetarySystem* _system, const string& _name) :
|
||||
names(1),
|
||||
localizedNameIndex(0),
|
||||
system(_system),
|
||||
satellites(NULL),
|
||||
timeline(NULL),
|
||||
frameTree(NULL),
|
||||
radius(1.0f),
|
||||
semiAxes(1.0f, 1.0f, 1.0f),
|
||||
mass(0.0f),
|
||||
albedo(0.5f),
|
||||
geometryOrientation(Quaternionf::Identity()),
|
||||
cullingRadius(0.0f),
|
||||
geometry(InvalidResource),
|
||||
geometryScale(1.0f),
|
||||
surface(Color(1.0f, 1.0f, 1.0f)),
|
||||
atmosphere(NULL),
|
||||
rings(NULL),
|
||||
classification(Unknown),
|
||||
altSurfaces(NULL),
|
||||
locations(NULL),
|
||||
locationsComputed(false),
|
||||
referenceMarks(NULL),
|
||||
visible(1),
|
||||
clickable(1),
|
||||
visibleAsPoint(1),
|
||||
overrideOrbitColor(0),
|
||||
orbitVisibility(UseClassVisibility),
|
||||
secondaryIlluminator(true)
|
||||
orbitVisibility(UseClassVisibility)
|
||||
{
|
||||
setName(_name);
|
||||
recomputeCullingRadius();
|
||||
|
@ -65,20 +39,19 @@ Body::Body(PlanetarySystem* _system, const string& _name) :
|
|||
|
||||
Body::~Body()
|
||||
{
|
||||
if (system != NULL)
|
||||
if (system)
|
||||
system->removeBody(this);
|
||||
// Remove from frame hierarchy
|
||||
|
||||
// Clean up the reference mark list
|
||||
if (referenceMarks != NULL)
|
||||
if (referenceMarks)
|
||||
{
|
||||
for (list<ReferenceMark*>::iterator iter = referenceMarks->begin(); iter != referenceMarks->end(); ++iter)
|
||||
delete *iter;
|
||||
for (const auto r : *referenceMarks)
|
||||
delete r;
|
||||
delete referenceMarks;
|
||||
}
|
||||
|
||||
delete timeline;
|
||||
|
||||
delete satellites;
|
||||
delete frameTree;
|
||||
}
|
||||
|
@ -98,9 +71,9 @@ void Body::setDefaultProperties()
|
|||
geometry = InvalidResource;
|
||||
surface = Surface(Color::White);
|
||||
delete atmosphere;
|
||||
atmosphere = NULL;
|
||||
atmosphere = nullptr;
|
||||
delete rings;
|
||||
rings = NULL;
|
||||
rings = nullptr;
|
||||
classification = Unknown;
|
||||
visible = 1;
|
||||
clickable = 1;
|
||||
|
@ -193,7 +166,7 @@ FrameTree* Body::getFrameTree() const
|
|||
|
||||
FrameTree* Body::getOrCreateFrameTree()
|
||||
{
|
||||
if (frameTree == NULL)
|
||||
if (!frameTree)
|
||||
frameTree = new FrameTree(this);
|
||||
return frameTree;
|
||||
}
|
||||
|
@ -218,14 +191,14 @@ void Body::setTimeline(Timeline* newTimeline)
|
|||
|
||||
void Body::markChanged()
|
||||
{
|
||||
if (timeline != NULL)
|
||||
if (timeline)
|
||||
timeline->markChanged();
|
||||
}
|
||||
|
||||
|
||||
void Body::markUpdated()
|
||||
{
|
||||
if (frameTree != NULL)
|
||||
if (frameTree)
|
||||
frameTree->markUpdated();
|
||||
}
|
||||
|
||||
|
@ -269,8 +242,8 @@ float Body::getBoundingRadius() const
|
|||
{
|
||||
if (geometry == InvalidResource)
|
||||
return radius;
|
||||
else
|
||||
return radius * 1.7320508f; // sqrt(3)
|
||||
|
||||
return radius * 1.7320508f; // sqrt(3)
|
||||
}
|
||||
|
||||
|
||||
|
@ -425,7 +398,7 @@ RingSystem* Body::getRings() const
|
|||
|
||||
void Body::setRings(const RingSystem& _rings)
|
||||
{
|
||||
if (rings == NULL)
|
||||
if (!rings)
|
||||
rings = new RingSystem(_rings);
|
||||
else
|
||||
*rings = _rings;
|
||||
|
@ -445,7 +418,7 @@ Atmosphere* Body::getAtmosphere()
|
|||
|
||||
void Body::setAtmosphere(const Atmosphere& _atmosphere)
|
||||
{
|
||||
if (atmosphere == NULL)
|
||||
if (!atmosphere)
|
||||
atmosphere = new Atmosphere();
|
||||
*atmosphere = _atmosphere;
|
||||
recomputeCullingRadius();
|
||||
|
@ -772,28 +745,23 @@ void Body::setClassification(int _classification)
|
|||
*/
|
||||
int Body::getOrbitClassification() const
|
||||
{
|
||||
if (classification != Invisible || frameTree == NULL)
|
||||
{
|
||||
if (classification != Invisible || !frameTree)
|
||||
return classification;
|
||||
}
|
||||
else
|
||||
{
|
||||
int orbitClass = frameTree->childClassMask();
|
||||
if (orbitClass & Planet)
|
||||
return Planet;
|
||||
else if (orbitClass & DwarfPlanet)
|
||||
return DwarfPlanet;
|
||||
else if (orbitClass & Moon)
|
||||
return Moon;
|
||||
else if (orbitClass & MinorMoon)
|
||||
return MinorMoon;
|
||||
else if (orbitClass & Asteroid)
|
||||
return Asteroid;
|
||||
else if (orbitClass & Spacecraft)
|
||||
return Spacecraft;
|
||||
else
|
||||
return Invisible;
|
||||
}
|
||||
|
||||
int orbitClass = frameTree->childClassMask();
|
||||
if ((orbitClass & Planet) != 0)
|
||||
return Planet;
|
||||
if ((orbitClass & DwarfPlanet) != 0)
|
||||
return DwarfPlanet;
|
||||
if ((orbitClass & Moon) != 0)
|
||||
return Moon;
|
||||
if ((orbitClass & MinorMoon) != 0)
|
||||
return MinorMoon;
|
||||
if ((orbitClass & Asteroid) != 0)
|
||||
return Asteroid;
|
||||
if ((orbitClass & Spacecraft) != 0)
|
||||
return Spacecraft;
|
||||
return Invisible;
|
||||
}
|
||||
|
||||
|
||||
|
@ -810,20 +778,20 @@ void Body::setInfoURL(const string& _infoURL)
|
|||
|
||||
Surface* Body::getAlternateSurface(const string& name) const
|
||||
{
|
||||
if (altSurfaces == NULL)
|
||||
return NULL;
|
||||
if (!altSurfaces)
|
||||
return nullptr;
|
||||
|
||||
AltSurfaceTable::iterator iter = altSurfaces->find(name);
|
||||
auto iter = altSurfaces->find(name);
|
||||
if (iter == altSurfaces->end())
|
||||
return NULL;
|
||||
else
|
||||
return iter->second;
|
||||
return nullptr;
|
||||
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
|
||||
void Body::addAlternateSurface(const string& name, Surface* surface)
|
||||
{
|
||||
if (altSurfaces == NULL)
|
||||
if (!altSurfaces)
|
||||
altSurfaces = new AltSurfaceTable();
|
||||
|
||||
//altSurfaces->insert(AltSurfaceTable::value_type(name, surface));
|
||||
|
@ -834,12 +802,11 @@ void Body::addAlternateSurface(const string& name, Surface* surface)
|
|||
vector<string>* Body::getAlternateSurfaceNames() const
|
||||
{
|
||||
vector<string>* names = new vector<string>();
|
||||
if (altSurfaces != NULL)
|
||||
if (altSurfaces)
|
||||
{
|
||||
for (AltSurfaceTable::const_iterator iter = altSurfaces->begin();
|
||||
iter != altSurfaces->end(); iter++)
|
||||
for (const auto& s : *altSurfaces)
|
||||
{
|
||||
names->insert(names->end(), iter->first);
|
||||
names->insert(names->end(), s.first);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -849,11 +816,11 @@ vector<string>* Body::getAlternateSurfaceNames() const
|
|||
|
||||
void Body::addLocation(Location* loc)
|
||||
{
|
||||
assert(loc != NULL);
|
||||
if (loc == NULL)
|
||||
assert(loc != nullptr);
|
||||
if (!loc)
|
||||
return;
|
||||
|
||||
if (locations == NULL)
|
||||
if (!locations)
|
||||
locations = new vector<Location*>();
|
||||
locations->insert(locations->end(), loc);
|
||||
loc->setParentBody(this);
|
||||
|
@ -868,17 +835,16 @@ vector<Location*>* Body::getLocations() const
|
|||
|
||||
Location* Body::findLocation(const string& name, bool i18n) const
|
||||
{
|
||||
if (locations == NULL)
|
||||
return NULL;
|
||||
if (!locations)
|
||||
return nullptr;
|
||||
|
||||
for (vector<Location*>::const_iterator iter = locations->begin();
|
||||
iter != locations->end(); iter++)
|
||||
for (const auto location : *locations)
|
||||
{
|
||||
if (!UTF8StringCompare(name, (*iter)->getName(i18n)))
|
||||
return *iter;
|
||||
if (!UTF8StringCompare(name, location->getName(i18n)))
|
||||
return location;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -898,17 +864,16 @@ void Body::computeLocations()
|
|||
if (geometry == InvalidResource)
|
||||
return;
|
||||
Geometry* g = GetGeometryManager()->find(geometry);
|
||||
if (g == NULL)
|
||||
if (!g)
|
||||
return;
|
||||
|
||||
// TODO: Implement separate radius and bounding radius so that this hack is
|
||||
// not necessary.
|
||||
double boundingRadius = 2.0;
|
||||
|
||||
for (vector<Location*>::const_iterator iter = locations->begin();
|
||||
iter != locations->end(); iter++)
|
||||
for (const auto location : *locations)
|
||||
{
|
||||
Vector3f v = (*iter)->getPosition();
|
||||
Vector3f v = location->getPosition();
|
||||
float alt = v.norm() - radius;
|
||||
if (alt != -radius)
|
||||
v.normalize();
|
||||
|
@ -919,7 +884,7 @@ void Body::computeLocations()
|
|||
if (g->pick(ray, t))
|
||||
{
|
||||
v *= (float) ((1.0 - t) * radius + alt);
|
||||
(*iter)->setPosition(v);
|
||||
location->setPosition(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -930,7 +895,7 @@ void Body::computeLocations()
|
|||
void
|
||||
Body::addReferenceMark(ReferenceMark* refMark)
|
||||
{
|
||||
if (referenceMarks == NULL)
|
||||
if (!referenceMarks)
|
||||
referenceMarks = new list<ReferenceMark*>();
|
||||
referenceMarks->push_back(refMark);
|
||||
recomputeCullingRadius();
|
||||
|
@ -942,10 +907,10 @@ Body::addReferenceMark(ReferenceMark* refMark)
|
|||
void
|
||||
Body::removeReferenceMark(const string& tag)
|
||||
{
|
||||
if (referenceMarks != NULL)
|
||||
if (referenceMarks)
|
||||
{
|
||||
ReferenceMark* refMark = findReferenceMark(tag);
|
||||
if (refMark != NULL)
|
||||
if (refMark)
|
||||
{
|
||||
referenceMarks->remove(refMark);
|
||||
delete refMark;
|
||||
|
@ -957,26 +922,26 @@ Body::removeReferenceMark(const string& tag)
|
|||
|
||||
/*! Find the first reference mark with the specified tag. If the body has
|
||||
* no reference marks with the specified tag, this method will return
|
||||
* NULL.
|
||||
* nullptr.
|
||||
*/
|
||||
ReferenceMark*
|
||||
Body::findReferenceMark(const string& tag) const
|
||||
{
|
||||
if (referenceMarks != NULL)
|
||||
if (referenceMarks)
|
||||
{
|
||||
for (list<ReferenceMark*>::iterator iter = referenceMarks->begin(); iter != referenceMarks->end(); ++iter)
|
||||
for (const auto rm : *referenceMarks)
|
||||
{
|
||||
if ((*iter)->getTag() == tag)
|
||||
return *iter;
|
||||
if (rm->getTag() == tag)
|
||||
return rm;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
/*! Get the list of reference marks associated with this body. May return
|
||||
* NULL if there are no reference marks.
|
||||
* nullptr if there are no reference marks.
|
||||
*/
|
||||
const list<ReferenceMark*>*
|
||||
Body::getReferenceMarks() const
|
||||
|
@ -1064,21 +1029,20 @@ void Body::recomputeCullingRadius()
|
|||
{
|
||||
float r = getBoundingRadius();
|
||||
|
||||
if (rings != NULL)
|
||||
if (rings)
|
||||
r = max(r, rings->outerRadius);
|
||||
|
||||
if (atmosphere != NULL)
|
||||
if (atmosphere)
|
||||
{
|
||||
r = max(r, atmosphere->height);
|
||||
r = max(r, atmosphere->cloudHeight);
|
||||
}
|
||||
|
||||
if (referenceMarks != NULL)
|
||||
if (referenceMarks)
|
||||
{
|
||||
for (std::list<ReferenceMark*>::const_iterator iter = referenceMarks->begin();
|
||||
iter != referenceMarks->end(); iter++)
|
||||
for (const auto rm : *referenceMarks)
|
||||
{
|
||||
r = max(r, (*iter)->boundingSphereRadius());
|
||||
r = max(r, rm->boundingSphereRadius());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1102,22 +1066,16 @@ void Body::recomputeCullingRadius()
|
|||
*/
|
||||
|
||||
PlanetarySystem::PlanetarySystem(Body* _primary) :
|
||||
star(NULL),
|
||||
star(nullptr),
|
||||
primary(_primary)
|
||||
{
|
||||
if (primary != NULL && primary->getSystem() != NULL)
|
||||
if (primary && primary->getSystem())
|
||||
star = primary->getSystem()->getStar();
|
||||
}
|
||||
|
||||
|
||||
PlanetarySystem::PlanetarySystem(Star* _star) :
|
||||
star(_star),
|
||||
primary(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PlanetarySystem::~PlanetarySystem()
|
||||
star(_star)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1162,9 +1120,9 @@ void PlanetarySystem::addBody(Body* body)
|
|||
void PlanetarySystem::addBodyToNameIndex(Body* body)
|
||||
{
|
||||
const vector<string>& names = body->getNames();
|
||||
for (vector<string>::const_iterator iter = names.begin(); iter != names.end(); iter++)
|
||||
for (const auto& name : names)
|
||||
{
|
||||
objectIndex.insert(make_pair(*iter, body));
|
||||
objectIndex.insert(make_pair(name, body));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1176,24 +1134,18 @@ void PlanetarySystem::removeBodyFromNameIndex(const Body* body)
|
|||
|
||||
// Erase the object from the object indices
|
||||
const vector<string>& names = body->getNames();
|
||||
for (vector<string>::const_iterator iter = names.begin(); iter != names.end(); iter++)
|
||||
for (const auto& name : names)
|
||||
{
|
||||
removeAlias(body, *iter);
|
||||
removeAlias(body, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PlanetarySystem::removeBody(Body* body)
|
||||
{
|
||||
for (vector<Body*>::iterator iter = satellites.begin();
|
||||
iter != satellites.end(); iter++)
|
||||
{
|
||||
if (*iter == body)
|
||||
{
|
||||
satellites.erase(iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto iter = std::find(satellites.begin(), satellites.end(), body);
|
||||
if (iter != satellites.end())
|
||||
satellites.erase(iter);
|
||||
|
||||
removeBodyFromNameIndex(body);
|
||||
}
|
||||
|
@ -1201,15 +1153,9 @@ void PlanetarySystem::removeBody(Body* body)
|
|||
|
||||
void PlanetarySystem::replaceBody(Body* oldBody, Body* newBody)
|
||||
{
|
||||
for (vector<Body*>::iterator iter = satellites.begin();
|
||||
iter != satellites.end(); iter++)
|
||||
{
|
||||
if (*iter == oldBody)
|
||||
{
|
||||
*iter = newBody;
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto iter = std::find(satellites.begin(), satellites.end(), oldBody);
|
||||
if (iter != satellites.end())
|
||||
*iter = newBody;
|
||||
|
||||
removeBodyFromNameIndex(oldBody);
|
||||
addBodyToNameIndex(newBody);
|
||||
|
@ -1226,42 +1172,34 @@ void PlanetarySystem::replaceBody(Body* oldBody, Body* newBody)
|
|||
*/
|
||||
Body* PlanetarySystem::find(const string& _name, bool deepSearch, bool i18n) const
|
||||
{
|
||||
ObjectIndex::const_iterator firstMatch = objectIndex.find(_name);
|
||||
auto firstMatch = objectIndex.find(_name);
|
||||
if (firstMatch != objectIndex.end())
|
||||
{
|
||||
Body* matchedBody = firstMatch->second;
|
||||
|
||||
if (i18n)
|
||||
{
|
||||
return matchedBody;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignore localized names
|
||||
if (!matchedBody->hasLocalizedName() || _name != matchedBody->getLocalizedName())
|
||||
return matchedBody;
|
||||
}
|
||||
// Ignore localized names
|
||||
if (!matchedBody->hasLocalizedName() || _name != matchedBody->getLocalizedName())
|
||||
return matchedBody;
|
||||
}
|
||||
|
||||
if (deepSearch)
|
||||
{
|
||||
for (vector<Body*>::const_iterator iter = satellites.begin();
|
||||
iter != satellites.end(); iter++)
|
||||
for (const auto sat : satellites)
|
||||
{
|
||||
if (UTF8StringCompare((*iter)->getName(i18n), _name) == 0)
|
||||
if (UTF8StringCompare(sat->getName(i18n), _name) == 0)
|
||||
return sat;
|
||||
if (sat->getSatellites())
|
||||
{
|
||||
return *iter;
|
||||
}
|
||||
else if (deepSearch && (*iter)->getSatellites() != NULL)
|
||||
{
|
||||
Body* body = (*iter)->getSatellites()->find(_name, deepSearch, i18n);
|
||||
if (body != NULL)
|
||||
Body* body = sat->getSatellites()->find(_name, deepSearch, i18n);
|
||||
if (body)
|
||||
return body;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1270,10 +1208,10 @@ bool PlanetarySystem::traverse(TraversalFunc func, void* info) const
|
|||
for (int i = 0; i < getSystemSize(); i++)
|
||||
{
|
||||
Body* body = getBody(i);
|
||||
// assert(body != NULL);
|
||||
// assert(body != nullptr);
|
||||
if (!func(body, info))
|
||||
return false;
|
||||
if (body->getSatellites() != NULL)
|
||||
if (body->getSatellites())
|
||||
{
|
||||
if (!body->getSatellites()->traverse(func, info))
|
||||
return false;
|
||||
|
@ -1289,10 +1227,9 @@ std::vector<std::string> PlanetarySystem::getCompletion(const std::string& _name
|
|||
int _name_length = UTF8Length(_name);
|
||||
|
||||
// Search through all names in this planetary system.
|
||||
for (ObjectIndex::const_iterator iter = objectIndex.begin();
|
||||
iter != objectIndex.end(); iter++)
|
||||
for (const auto& index : objectIndex)
|
||||
{
|
||||
const string& alias = iter->first;
|
||||
const string& alias = index.first;
|
||||
|
||||
if (UTF8StringCompare(alias, _name, _name_length) == 0)
|
||||
{
|
||||
|
@ -1303,12 +1240,11 @@ std::vector<std::string> PlanetarySystem::getCompletion(const std::string& _name
|
|||
// Scan child objects
|
||||
if (deepSearch)
|
||||
{
|
||||
for (vector<Body*>::const_iterator iter = satellites.begin();
|
||||
iter != satellites.end(); iter++)
|
||||
for (const auto sat : satellites)
|
||||
{
|
||||
if ((*iter)->getSatellites() != NULL)
|
||||
if (sat->getSatellites())
|
||||
{
|
||||
vector<string> bodies = (*iter)->getSatellites()->getCompletion(_name);
|
||||
auto bodies = sat->getSatellites()->getCompletion(_name);
|
||||
completion.insert(completion.end(), bodies.begin(), bodies.end());
|
||||
}
|
||||
}
|
||||
|
@ -1323,9 +1259,9 @@ std::vector<std::string> PlanetarySystem::getCompletion(const std::string& _name
|
|||
*/
|
||||
int PlanetarySystem::getOrder(const Body* body) const
|
||||
{
|
||||
vector<Body*>::const_iterator iter = std::find(satellites.begin(), satellites.end(), body);
|
||||
auto iter = std::find(satellites.begin(), satellites.end(), body);
|
||||
if (iter == satellites.end())
|
||||
return -1;
|
||||
else
|
||||
return iter - satellites.begin();
|
||||
|
||||
return iter - satellites.begin();
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class PlanetarySystem
|
|||
public:
|
||||
PlanetarySystem(Body* _primary);
|
||||
PlanetarySystem(Star* _star);
|
||||
~PlanetarySystem();
|
||||
~PlanetarySystem() = default;
|
||||
|
||||
Star* getStar() const { return star; };
|
||||
Body* getPrimaryBody() const { return primary; };
|
||||
|
@ -71,7 +71,7 @@ class PlanetarySystem
|
|||
|
||||
private:
|
||||
Star* star;
|
||||
Body* primary;
|
||||
Body* primary{nullptr};
|
||||
std::vector<Body*> satellites;
|
||||
ObjectIndex objectIndex; // index of bodies by name
|
||||
};
|
||||
|
@ -337,57 +337,57 @@ class Body
|
|||
void markUpdated();
|
||||
|
||||
private:
|
||||
void setName(const std::string& _name);
|
||||
void setName(const std::string& name);
|
||||
void recomputeCullingRadius();
|
||||
|
||||
private:
|
||||
std::vector<std::string> names;
|
||||
unsigned int localizedNameIndex;
|
||||
std::vector<std::string> names{ 1 };
|
||||
unsigned int localizedNameIndex{ 0 };
|
||||
|
||||
// Parent in the name hierarchy
|
||||
PlanetarySystem* system;
|
||||
// Children in the name hierarchy
|
||||
PlanetarySystem* satellites;
|
||||
PlanetarySystem* satellites{ nullptr };
|
||||
|
||||
Timeline* timeline;
|
||||
Timeline* timeline{ nullptr };
|
||||
// Children in the frame hierarchy
|
||||
FrameTree* frameTree;
|
||||
FrameTree* frameTree{ nullptr };
|
||||
|
||||
float radius;
|
||||
Eigen::Vector3f semiAxes;
|
||||
float mass;
|
||||
float albedo;
|
||||
Eigen::Quaternionf geometryOrientation;
|
||||
float radius{ 1.0f };
|
||||
Eigen::Vector3f semiAxes{ 1.0f, 1.0f, 1.0f };
|
||||
float mass{ 0.0f };
|
||||
float albedo{ 0.5f };
|
||||
Eigen::Quaternionf geometryOrientation{ Eigen::Quaternionf::Identity() };
|
||||
|
||||
float cullingRadius;
|
||||
float cullingRadius{ 0.0f };
|
||||
|
||||
ResourceHandle geometry;
|
||||
float geometryScale;
|
||||
Surface surface;
|
||||
ResourceHandle geometry{ InvalidResource };
|
||||
float geometryScale{ 1.0f };
|
||||
Surface surface{ Color(1.0f, 1.0f, 1.0f) };
|
||||
|
||||
Atmosphere* atmosphere;
|
||||
RingSystem* rings;
|
||||
Atmosphere* atmosphere{ nullptr };
|
||||
RingSystem* rings{ nullptr };
|
||||
|
||||
int classification;
|
||||
int classification{ Unknown };
|
||||
|
||||
std::string infoURL;
|
||||
|
||||
typedef std::map<std::string, Surface*> AltSurfaceTable;
|
||||
AltSurfaceTable *altSurfaces;
|
||||
AltSurfaceTable *altSurfaces{ nullptr };
|
||||
|
||||
std::vector<Location*>* locations;
|
||||
mutable bool locationsComputed;
|
||||
std::vector<Location*>* locations{ nullptr };
|
||||
mutable bool locationsComputed{ false };
|
||||
|
||||
std::list<ReferenceMark*>* referenceMarks;
|
||||
std::list<ReferenceMark*>* referenceMarks{ nullptr };
|
||||
|
||||
Color orbitColor;
|
||||
|
||||
unsigned int visible : 1;
|
||||
unsigned int clickable : 1;
|
||||
unsigned int visibleAsPoint : 1;
|
||||
unsigned int overrideOrbitColor : 1;
|
||||
bool visible{ true };
|
||||
bool clickable{ true };
|
||||
bool visibleAsPoint{ true };
|
||||
bool overrideOrbitColor{ false };
|
||||
VisibilityPolicy orbitVisibility : 3;
|
||||
bool secondaryIlluminator : 1;
|
||||
bool secondaryIlluminator{ true };
|
||||
};
|
||||
|
||||
#endif // _CELENGINE_BODY_H_
|
||||
|
|
|
@ -21,20 +21,16 @@ using namespace std;
|
|||
static const float BoundariesDrawDistance = 10000.0f;
|
||||
|
||||
|
||||
ConstellationBoundaries::ConstellationBoundaries() :
|
||||
currentChain(NULL)
|
||||
ConstellationBoundaries::ConstellationBoundaries()
|
||||
{
|
||||
currentChain = new Chain();
|
||||
currentChain->insert(currentChain->end(), Vector3f::Zero());
|
||||
currentChain->push_back(Vector3f::Zero());
|
||||
}
|
||||
|
||||
ConstellationBoundaries::~ConstellationBoundaries()
|
||||
{
|
||||
for (vector<Chain*>::iterator iter = chains.begin();
|
||||
iter != chains.end(); iter++)
|
||||
{
|
||||
delete *iter;
|
||||
}
|
||||
for (const auto chain : chains)
|
||||
delete chain;
|
||||
|
||||
delete currentChain;
|
||||
}
|
||||
|
@ -42,7 +38,7 @@ ConstellationBoundaries::~ConstellationBoundaries()
|
|||
|
||||
void ConstellationBoundaries::moveto(float ra, float dec)
|
||||
{
|
||||
assert(currentChain != NULL);
|
||||
assert(currentChain != nullptr);
|
||||
|
||||
Vector3f v = astro::equatorialToEclipticCartesian(ra, dec, BoundariesDrawDistance);
|
||||
if (currentChain->size() > 1)
|
||||
|
@ -66,15 +62,12 @@ void ConstellationBoundaries::lineto(float ra, float dec)
|
|||
|
||||
void ConstellationBoundaries::render()
|
||||
{
|
||||
for (vector<Chain*>::iterator iter = chains.begin();
|
||||
iter != chains.end(); iter++)
|
||||
for (const auto chain : chains)
|
||||
{
|
||||
Chain* chain = *iter;
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (Chain::iterator citer = chain->begin(); citer != chain->end();
|
||||
citer++)
|
||||
for (const auto& c : *chain)
|
||||
{
|
||||
glVertex3fv(citer->data());
|
||||
glVertex3fv(c.data());
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
@ -83,7 +76,7 @@ void ConstellationBoundaries::render()
|
|||
|
||||
ConstellationBoundaries* ReadBoundaries(istream& in)
|
||||
{
|
||||
ConstellationBoundaries* boundaries = new ConstellationBoundaries();
|
||||
auto* boundaries = new ConstellationBoundaries();
|
||||
string lastCon;
|
||||
int conCount = 0;
|
||||
int ptCount = 0;
|
||||
|
|
|
@ -29,7 +29,7 @@ class ConstellationBoundaries
|
|||
void render();
|
||||
|
||||
private:
|
||||
Chain* currentChain;
|
||||
Chain* currentChain{nullptr};
|
||||
std::vector<Chain*> chains;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,15 +16,6 @@
|
|||
using namespace std;
|
||||
|
||||
|
||||
CatalogCrossReference::CatalogCrossReference()
|
||||
{
|
||||
}
|
||||
|
||||
CatalogCrossReference::~CatalogCrossReference()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
string CatalogCrossReference::getPrefix() const
|
||||
{
|
||||
return prefix;
|
||||
|
@ -44,9 +35,7 @@ bool operator<(const CatalogCrossReference::Entry& a,
|
|||
|
||||
struct XrefEntryPredicate
|
||||
{
|
||||
int dummy;
|
||||
|
||||
XrefEntryPredicate() : dummy(0) {};
|
||||
int dummy{0};
|
||||
|
||||
bool operator()(const CatalogCrossReference::Entry& a,
|
||||
const CatalogCrossReference::Entry& b) const
|
||||
|
@ -60,7 +49,7 @@ Star* CatalogCrossReference::lookup(uint32 catalogNumber) const
|
|||
{
|
||||
Entry e;
|
||||
e.catalogNumber = catalogNumber;
|
||||
e.star = NULL;
|
||||
e.star = nullptr;
|
||||
|
||||
XrefEntryPredicate pred;
|
||||
vector<Entry>::const_iterator iter = lower_bound(entries.begin(),
|
||||
|
@ -68,8 +57,8 @@ Star* CatalogCrossReference::lookup(uint32 catalogNumber) const
|
|||
|
||||
if (iter != entries.end() && iter->catalogNumber == catalogNumber)
|
||||
return iter->star;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,9 +66,9 @@ Star* CatalogCrossReference::lookup(const string& name) const
|
|||
{
|
||||
uint32 catalogNumber = parse(name);
|
||||
if (catalogNumber == InvalidCatalogNumber)
|
||||
return NULL;
|
||||
else
|
||||
return lookup(catalogNumber);
|
||||
return nullptr;
|
||||
|
||||
return lookup(catalogNumber);
|
||||
}
|
||||
|
||||
|
||||
|
@ -113,8 +102,8 @@ uint32 CatalogCrossReference::parse(const string& name) const
|
|||
// Check for garbage at the end of the string
|
||||
if (i != prefix.length())
|
||||
return InvalidCatalogNumber;
|
||||
else
|
||||
return n;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,20 +134,20 @@ static uint32 readUint32(istream& in)
|
|||
unsigned char b[4];
|
||||
in.read(reinterpret_cast<char*>(b), 4);
|
||||
return ((uint32) b[3] << 24) + ((uint32) b[2] << 16)
|
||||
+ ((uint32) b[1] << 8) + (uint32) b[0];
|
||||
+ ((uint32) b[1] << 8) + (uint32) b[0];
|
||||
}
|
||||
|
||||
|
||||
CatalogCrossReference* ReadCatalogCrossReference(istream& in,
|
||||
const StarDatabase& stardb)
|
||||
{
|
||||
CatalogCrossReference* xref = new CatalogCrossReference();
|
||||
auto* xref = new CatalogCrossReference();
|
||||
|
||||
uint32 nEntries = readUint32(in);
|
||||
if (!in.good())
|
||||
{
|
||||
delete xref;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
xref->reserve(nEntries);
|
||||
|
@ -168,7 +157,7 @@ CatalogCrossReference* ReadCatalogCrossReference(istream& in,
|
|||
uint32 catNo1 = readUint32(in);
|
||||
uint32 catNo2 = readUint32(in);
|
||||
Star* star = stardb.find(catNo2);
|
||||
if (star != NULL)
|
||||
if (star != nullptr)
|
||||
xref->addEntry(catNo1, star);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
class CatalogCrossReference
|
||||
{
|
||||
public:
|
||||
CatalogCrossReference();
|
||||
~CatalogCrossReference();
|
||||
CatalogCrossReference() = default;
|
||||
~CatalogCrossReference() = default;
|
||||
|
||||
std::string getPrefix() const;
|
||||
void setPrefix(const std::string&);
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
using namespace std;
|
||||
|
||||
|
||||
static int parseRenderFlags(string);
|
||||
static int parseLabelFlags(string);
|
||||
static int parseOrbitFlags(string);
|
||||
static int parseRenderFlags(string /*s*/);
|
||||
static int parseLabelFlags(string /*s*/);
|
||||
static int parseOrbitFlags(string /*s*/);
|
||||
static int parseConstellations(CommandConstellations* cmd, string s, int act);
|
||||
int parseConstellationColor(CommandConstellationColor* cmd, string s, Vec3d *col, int act);
|
||||
|
||||
|
@ -68,7 +68,7 @@ CommandSequence* CommandParser::parse()
|
|||
{
|
||||
error("'{' expected at start of script.");
|
||||
delete seq;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Tokenizer::TokenType ttype = tokenizer->nextToken();
|
||||
|
@ -76,16 +76,11 @@ CommandSequence* CommandParser::parse()
|
|||
{
|
||||
tokenizer->pushBack();
|
||||
Command* cmd = parseCommand();
|
||||
if (cmd == NULL)
|
||||
if (cmd == nullptr)
|
||||
{
|
||||
for (CommandSequence::const_iterator iter = seq->begin();
|
||||
iter != seq->end();
|
||||
iter++)
|
||||
{
|
||||
delete *iter;
|
||||
}
|
||||
for_each(seq->begin(), seq->end(), deleteFunc<Command*>());;
|
||||
delete seq;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -100,7 +95,7 @@ CommandSequence* CommandParser::parse()
|
|||
error("Missing '}' at end of script.");
|
||||
for_each(seq->begin(), seq->end(), deleteFunc<Command*>());;
|
||||
delete seq;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return seq;
|
||||
|
@ -149,20 +144,20 @@ Command* CommandParser::parseCommand()
|
|||
if (tokenizer->nextToken() != Tokenizer::TokenName)
|
||||
{
|
||||
error("Invalid command name");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
string commandName = tokenizer->getStringValue();
|
||||
|
||||
Value* paramListValue = parser->readValue();
|
||||
if (paramListValue == NULL || paramListValue->getType() != Value::HashType)
|
||||
if (paramListValue == nullptr || paramListValue->getType() != Value::HashType)
|
||||
{
|
||||
error("Bad parameter list");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Hash* paramList = paramListValue->getHash();
|
||||
Command* cmd = NULL;
|
||||
Command* cmd = nullptr;
|
||||
|
||||
if (commandName == "wait")
|
||||
{
|
||||
|
@ -820,7 +815,7 @@ Command* CommandParser::parseCommand()
|
|||
else
|
||||
{
|
||||
error("Unknown command name '" + commandName + "'");
|
||||
cmd = NULL;
|
||||
cmd = nullptr;
|
||||
}
|
||||
|
||||
delete paramListValue;
|
||||
|
@ -931,11 +926,11 @@ int parseConstellations(CommandConstellations* cmd, string s, int act)
|
|||
{
|
||||
string name = tokenizer.getNameValue();
|
||||
if (compareIgnoringCase(name, "all") == 0 && act==1)
|
||||
cmd->all=1;
|
||||
cmd->flags.all = true;
|
||||
else if (compareIgnoringCase(name, "all") == 0 && act==0)
|
||||
cmd->none=1;
|
||||
cmd->flags.none = true;
|
||||
else
|
||||
cmd->setValues(name,act);
|
||||
cmd->setValues(name, act);
|
||||
|
||||
ttype = tokenizer.nextToken();
|
||||
if (ttype == Tokenizer::TokenBar)
|
||||
|
@ -970,9 +965,9 @@ int parseConstellationColor(CommandConstellationColor* cmd, string s, Vec3d *col
|
|||
{
|
||||
string name = tokenizer.getNameValue();
|
||||
if (compareIgnoringCase(name, "all") == 0 && act==1)
|
||||
cmd->all=1;
|
||||
cmd->flags.all = true;
|
||||
else if (compareIgnoringCase(name, "all") == 0 && act==0)
|
||||
cmd->none=1;
|
||||
cmd->flags.none = true;
|
||||
else
|
||||
cmd->setConstellations(name);
|
||||
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
#include <celestia/celx_internal.h>
|
||||
#include <celutil/util.h>
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
#include "eigenport.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -29,11 +31,7 @@ CommandWait::CommandWait(double _duration) : TimedCommand(_duration)
|
|||
{
|
||||
}
|
||||
|
||||
CommandWait::~CommandWait()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandWait::process(ExecutionEnvironment&, double, double)
|
||||
void CommandWait::process(ExecutionEnvironment& /*unused*/, double /*unused*/, double /*unused*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -41,11 +39,7 @@ void CommandWait::process(ExecutionEnvironment&, double, double)
|
|||
////////////////
|
||||
// Select command: select a body
|
||||
|
||||
CommandSelect::CommandSelect(string _target) : target(_target)
|
||||
{
|
||||
}
|
||||
|
||||
CommandSelect::~CommandSelect()
|
||||
CommandSelect::CommandSelect(string _target) : target(std::move(_target))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -68,10 +62,6 @@ CommandGoto::CommandGoto(double t,
|
|||
{
|
||||
}
|
||||
|
||||
CommandGoto::~CommandGoto()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandGoto::process(ExecutionEnvironment& env)
|
||||
{
|
||||
Selection sel = env.getSimulation()->getSelection();
|
||||
|
@ -97,10 +87,6 @@ CommandGotoLongLat::CommandGotoLongLat(double t,
|
|||
{
|
||||
}
|
||||
|
||||
CommandGotoLongLat::~CommandGotoLongLat()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandGotoLongLat::process(ExecutionEnvironment& env)
|
||||
{
|
||||
Selection sel = env.getSimulation()->getSelection();
|
||||
|
@ -121,10 +107,6 @@ CommandGotoLocation::CommandGotoLocation(double t,
|
|||
{
|
||||
}
|
||||
|
||||
CommandGotoLocation::~CommandGotoLocation()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandGotoLocation::process(ExecutionEnvironment& env)
|
||||
{
|
||||
Quatd toOrientation = Quatd(rotation.w, rotation.x, rotation.y, rotation.z);
|
||||
|
@ -135,8 +117,8 @@ void CommandGotoLocation::process(ExecutionEnvironment& env)
|
|||
/////////////////////////////
|
||||
// SetUrl
|
||||
|
||||
CommandSetUrl::CommandSetUrl(const std::string& _url) :
|
||||
url(_url)
|
||||
CommandSetUrl::CommandSetUrl(std::string _url) :
|
||||
url(std::move(_url))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -153,10 +135,6 @@ CommandCenter::CommandCenter(double t) : centerTime(t)
|
|||
{
|
||||
}
|
||||
|
||||
CommandCenter::~CommandCenter()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandCenter::process(ExecutionEnvironment& env)
|
||||
{
|
||||
env.getSimulation()->centerSelection(centerTime);
|
||||
|
@ -166,10 +144,6 @@ void CommandCenter::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// Follow command: follow the selected body
|
||||
|
||||
CommandFollow::CommandFollow()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandFollow::process(ExecutionEnvironment& env)
|
||||
{
|
||||
env.getSimulation()->follow();
|
||||
|
@ -180,10 +154,6 @@ void CommandFollow::process(ExecutionEnvironment& env)
|
|||
// Synchronous command: maintain the current position relative to the
|
||||
// surface of the currently selected object.
|
||||
|
||||
CommandSynchronous::CommandSynchronous()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandSynchronous::process(ExecutionEnvironment& env)
|
||||
{
|
||||
env.getSimulation()->geosynchronousFollow();
|
||||
|
@ -193,10 +163,6 @@ void CommandSynchronous::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// Chase command:
|
||||
|
||||
CommandChase::CommandChase()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandChase::process(ExecutionEnvironment& env)
|
||||
{
|
||||
env.getSimulation()->chase();
|
||||
|
@ -206,10 +172,6 @@ void CommandChase::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// Track command:
|
||||
|
||||
CommandTrack::CommandTrack()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandTrack::process(ExecutionEnvironment& env)
|
||||
{
|
||||
env.getSimulation()->setTrackedObject(env.getSimulation()->getSelection());
|
||||
|
@ -219,10 +181,6 @@ void CommandTrack::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// Lock command:
|
||||
|
||||
CommandLock::CommandLock()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandLock::process(ExecutionEnvironment& env)
|
||||
{
|
||||
env.getSimulation()->phaseLock();
|
||||
|
@ -234,9 +192,9 @@ void CommandLock::process(ExecutionEnvironment& env)
|
|||
// Setframe command
|
||||
|
||||
CommandSetFrame::CommandSetFrame(ObserverFrame::CoordinateSystem _coordSys,
|
||||
const string& refName,
|
||||
const string& targetName) :
|
||||
coordSys(_coordSys), refObjectName(refName), targetObjectName(targetName)
|
||||
string refName,
|
||||
string targetName) :
|
||||
coordSys(_coordSys), refObjectName(std::move(refName)), targetObjectName(std::move(targetName))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -253,8 +211,8 @@ void CommandSetFrame::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// SetSurface command: select an alternate surface to show
|
||||
|
||||
CommandSetSurface::CommandSetSurface(const string& _surfaceName) :
|
||||
surfaceName(_surfaceName)
|
||||
CommandSetSurface::CommandSetSurface(string _surfaceName) :
|
||||
surfaceName(std::move(_surfaceName))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -268,10 +226,6 @@ void CommandSetSurface::process(ExecutionEnvironment& env)
|
|||
// Cancel command: stop all motion, set the coordinate system to absolute,
|
||||
// and cancel any tracking
|
||||
|
||||
CommandCancel::CommandCancel()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandCancel::process(ExecutionEnvironment& env)
|
||||
{
|
||||
env.getSimulation()->cancelMotion();
|
||||
|
@ -286,7 +240,7 @@ void CommandCancel::process(ExecutionEnvironment& env)
|
|||
CommandPrint::CommandPrint(string _text,
|
||||
int horig, int vorig, int hoff, int voff,
|
||||
double _duration
|
||||
) : text(_text),
|
||||
) : text(std::move(_text)),
|
||||
hOrigin(horig), vOrigin(vorig),
|
||||
hOffset(hoff), vOffset(voff),
|
||||
duration(_duration)
|
||||
|
@ -302,11 +256,7 @@ void CommandPrint::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// Clear screen command: clear the console of all text
|
||||
|
||||
CommandClearScreen::CommandClearScreen()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandClearScreen::process(ExecutionEnvironment&)
|
||||
void CommandClearScreen::process(ExecutionEnvironment& /*unused*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -314,11 +264,7 @@ void CommandClearScreen::process(ExecutionEnvironment&)
|
|||
////////////////
|
||||
// Exit command: quit the program
|
||||
|
||||
CommandExit::CommandExit()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandExit::process(ExecutionEnvironment&)
|
||||
void CommandExit::process(ExecutionEnvironment& /*unused*/)
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
@ -359,7 +305,7 @@ CommandChangeDistance::CommandChangeDistance(double _duration, double _rate) :
|
|||
{
|
||||
}
|
||||
|
||||
void CommandChangeDistance::process(ExecutionEnvironment& env, double, double dt)
|
||||
void CommandChangeDistance::process(ExecutionEnvironment& env, double /*unused*/, double dt)
|
||||
{
|
||||
env.getSimulation()->changeOrbitDistance((float) (rate * dt));
|
||||
}
|
||||
|
@ -374,7 +320,7 @@ CommandOrbit::CommandOrbit(double _duration, const Vec3f& axis, float rate) :
|
|||
{
|
||||
}
|
||||
|
||||
void CommandOrbit::process(ExecutionEnvironment& env, double, double dt)
|
||||
void CommandOrbit::process(ExecutionEnvironment& env, double /*unused*/, double dt)
|
||||
{
|
||||
float v = spin.length();
|
||||
if (v != 0.0f)
|
||||
|
@ -392,7 +338,7 @@ CommandRotate::CommandRotate(double _duration, const Vec3f& axis, float rate) :
|
|||
{
|
||||
}
|
||||
|
||||
void CommandRotate::process(ExecutionEnvironment& env, double, double dt)
|
||||
void CommandRotate::process(ExecutionEnvironment& env, double /*unused*/, double dt)
|
||||
{
|
||||
float v = spin.length();
|
||||
if (v != 0.0f)
|
||||
|
@ -410,7 +356,7 @@ CommandMove::CommandMove(double _duration, const Vec3d& _velocity) :
|
|||
{
|
||||
}
|
||||
|
||||
void CommandMove::process(ExecutionEnvironment& env, double, double dt)
|
||||
void CommandMove::process(ExecutionEnvironment& env, double /*unused*/, double dt)
|
||||
{
|
||||
Eigen::Vector3d velocityKm = toEigen(velocity) * dt * astro::microLightYearsToKilometers(1.0);
|
||||
env.getSimulation()->setObserverPosition(env.getSimulation()->getObserver().getPosition().offsetKm(velocityKm));
|
||||
|
@ -448,10 +394,6 @@ void CommandSetOrientation::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// Look back command: reverse observer orientation
|
||||
|
||||
CommandLookBack::CommandLookBack()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandLookBack::process(ExecutionEnvironment& env)
|
||||
{
|
||||
env.getSimulation()->reverseObserverOrientation();
|
||||
|
@ -468,7 +410,7 @@ CommandRenderFlags::CommandRenderFlags(int _setFlags, int _clearFlags) :
|
|||
void CommandRenderFlags::process(ExecutionEnvironment& env)
|
||||
{
|
||||
Renderer* r = env.getRenderer();
|
||||
if (r != NULL)
|
||||
if (r != nullptr)
|
||||
{
|
||||
r->setRenderFlags(r->getRenderFlags() | setFlags);
|
||||
r->setRenderFlags(r->getRenderFlags() & ~clearFlags);
|
||||
|
@ -487,7 +429,7 @@ CommandLabels::CommandLabels(int _setFlags, int _clearFlags) :
|
|||
void CommandLabels::process(ExecutionEnvironment& env)
|
||||
{
|
||||
Renderer* r = env.getRenderer();
|
||||
if (r != NULL)
|
||||
if (r != nullptr)
|
||||
{
|
||||
r->setLabelMode(r->getLabelMode() | setFlags);
|
||||
r->setLabelMode(r->getLabelMode() & ~clearFlags);
|
||||
|
@ -506,7 +448,7 @@ CommandOrbitFlags::CommandOrbitFlags(int _setFlags, int _clearFlags) :
|
|||
void CommandOrbitFlags::process(ExecutionEnvironment& env)
|
||||
{
|
||||
Renderer* r = env.getRenderer();
|
||||
if (r != NULL)
|
||||
if (r != nullptr)
|
||||
{
|
||||
r->setOrbitMask(r->getOrbitMask() | setFlags);
|
||||
r->setOrbitMask(r->getOrbitMask() & ~clearFlags);
|
||||
|
@ -538,7 +480,7 @@ CommandSetFaintestAutoMag45deg::CommandSetFaintestAutoMag45deg(double mag) :
|
|||
void CommandSetFaintestAutoMag45deg::process(ExecutionEnvironment& env)
|
||||
{
|
||||
Renderer* r = env.getRenderer();
|
||||
if (r != NULL)
|
||||
if (r != nullptr)
|
||||
r->setFaintestAM45deg((float) magnitude);
|
||||
}
|
||||
|
||||
|
@ -553,7 +495,7 @@ CommandSetAmbientLight::CommandSetAmbientLight(float level) :
|
|||
void CommandSetAmbientLight::process(ExecutionEnvironment& env)
|
||||
{
|
||||
Renderer* r = env.getRenderer();
|
||||
if (r != NULL)
|
||||
if (r != nullptr)
|
||||
r->setAmbientLightLevel(lightLevel);
|
||||
}
|
||||
|
||||
|
@ -574,8 +516,8 @@ void CommandSetGalaxyLightGain::process(ExecutionEnvironment& /* env */)
|
|||
////////////////
|
||||
// Set command
|
||||
|
||||
CommandSet::CommandSet(const std::string& _name, double _value) :
|
||||
name(_name), value(_value)
|
||||
CommandSet::CommandSet(std::string _name, double _value) :
|
||||
name(std::move(_name)), value(_value)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -583,22 +525,22 @@ void CommandSet::process(ExecutionEnvironment& env)
|
|||
{
|
||||
if (compareIgnoringCase(name, "MinOrbitSize") == 0)
|
||||
{
|
||||
if (env.getRenderer() != NULL)
|
||||
if (env.getRenderer() != nullptr)
|
||||
env.getRenderer()->setMinimumOrbitSize((float) value);
|
||||
}
|
||||
else if (compareIgnoringCase(name, "AmbientLightLevel") == 0)
|
||||
{
|
||||
if (env.getRenderer() != NULL)
|
||||
if (env.getRenderer() != nullptr)
|
||||
env.getRenderer()->setAmbientLightLevel((float) value);
|
||||
}
|
||||
else if (compareIgnoringCase(name, "FOV") == 0)
|
||||
{
|
||||
if (env.getRenderer() != NULL)
|
||||
if (env.getRenderer() != nullptr)
|
||||
env.getSimulation()->getActiveObserver()->setFOV(degToRad((float) value));
|
||||
}
|
||||
else if (compareIgnoringCase(name, "StarDistanceLimit") == 0)
|
||||
{
|
||||
if (env.getRenderer() != NULL)
|
||||
if (env.getRenderer() != nullptr)
|
||||
env.getRenderer()->setDistanceLimit((float) value);
|
||||
}
|
||||
else if (compareIgnoringCase(name, "StarStyle") == 0)
|
||||
|
@ -606,7 +548,7 @@ void CommandSet::process(ExecutionEnvironment& env)
|
|||
// The cast from double to an enum requires an intermediate cast to int
|
||||
// Probably shouldn't be doing this at all, but other alternatives
|
||||
// are more trouble than they're worth.
|
||||
if (env.getRenderer() != NULL)
|
||||
if (env.getRenderer() != nullptr)
|
||||
env.getRenderer()->setStarStyle((Renderer::StarStyle) (int) value);
|
||||
}
|
||||
}
|
||||
|
@ -615,10 +557,10 @@ void CommandSet::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// Mark object command
|
||||
|
||||
CommandMark::CommandMark(const string& _target,
|
||||
CommandMark::CommandMark(string _target,
|
||||
MarkerRepresentation _rep,
|
||||
bool _occludable) :
|
||||
target(_target),
|
||||
target(std::move(_target)),
|
||||
rep(_rep),
|
||||
occludable(_occludable)
|
||||
{
|
||||
|
@ -630,7 +572,7 @@ void CommandMark::process(ExecutionEnvironment& env)
|
|||
if (sel.empty())
|
||||
return;
|
||||
|
||||
if (env.getSimulation()->getUniverse() != NULL)
|
||||
if (env.getSimulation()->getUniverse() != nullptr)
|
||||
{
|
||||
|
||||
env.getSimulation()->getUniverse()->markObject(sel, rep, 1, occludable);
|
||||
|
@ -642,8 +584,8 @@ void CommandMark::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// Unmark object command
|
||||
|
||||
CommandUnmark::CommandUnmark(const string& _target) :
|
||||
target(_target)
|
||||
CommandUnmark::CommandUnmark(string _target) :
|
||||
target(std::move(_target))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -653,7 +595,7 @@ void CommandUnmark::process(ExecutionEnvironment& env)
|
|||
if (sel.empty())
|
||||
return;
|
||||
|
||||
if (env.getSimulation()->getUniverse() != NULL)
|
||||
if (env.getSimulation()->getUniverse() != nullptr)
|
||||
env.getSimulation()->getUniverse()->unmarkObject(sel, 1);
|
||||
}
|
||||
|
||||
|
@ -662,13 +604,9 @@ void CommandUnmark::process(ExecutionEnvironment& env)
|
|||
///////////////
|
||||
// Unmarkall command - clear all current markers
|
||||
|
||||
CommandUnmarkAll::CommandUnmarkAll()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandUnmarkAll::process(ExecutionEnvironment& env)
|
||||
{
|
||||
if (env.getSimulation()->getUniverse() != NULL)
|
||||
if (env.getSimulation()->getUniverse() != nullptr)
|
||||
env.getSimulation()->getUniverse()->unmarkAll();
|
||||
}
|
||||
|
||||
|
@ -676,18 +614,18 @@ void CommandUnmarkAll::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// Preload textures command
|
||||
|
||||
CommandPreloadTextures::CommandPreloadTextures(const string& _name) :
|
||||
name(_name)
|
||||
CommandPreloadTextures::CommandPreloadTextures(string _name) :
|
||||
name(std::move(_name))
|
||||
{
|
||||
}
|
||||
|
||||
void CommandPreloadTextures::process(ExecutionEnvironment& env)
|
||||
{
|
||||
Selection target = env.getSimulation()->findObjectFromPath(name);
|
||||
if (target.body() == NULL)
|
||||
if (target.body() == nullptr)
|
||||
return;
|
||||
|
||||
if (env.getRenderer() != NULL)
|
||||
if (env.getRenderer() != nullptr)
|
||||
env.getRenderer()->loadTextures(target.body());
|
||||
}
|
||||
|
||||
|
@ -695,12 +633,12 @@ void CommandPreloadTextures::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// Capture command
|
||||
|
||||
CommandCapture::CommandCapture(const std::string& _type,
|
||||
const std::string& _filename) : type(_type), filename(_filename)
|
||||
CommandCapture::CommandCapture(std::string _type,
|
||||
std::string _filename) : type(std::move(_type)), filename(std::move(_filename))
|
||||
{
|
||||
}
|
||||
|
||||
void CommandCapture::process(ExecutionEnvironment&)
|
||||
void CommandCapture::process(ExecutionEnvironment& /*unused*/)
|
||||
{
|
||||
#ifndef TARGET_OS_MAC
|
||||
// Get the dimensions of the current viewport
|
||||
|
@ -713,7 +651,7 @@ void CommandCapture::process(ExecutionEnvironment&)
|
|||
viewport[0], viewport[1],
|
||||
viewport[2], viewport[3]);
|
||||
}
|
||||
if (compareIgnoringCase(type, "png") == 0)
|
||||
else if (compareIgnoringCase(type, "png") == 0)
|
||||
{
|
||||
CaptureGLBufferToPNG(filename,
|
||||
viewport[0], viewport[1],
|
||||
|
@ -733,7 +671,7 @@ CommandSetTextureResolution::CommandSetTextureResolution(unsigned int _res) :
|
|||
|
||||
void CommandSetTextureResolution::process(ExecutionEnvironment& env)
|
||||
{
|
||||
if (env.getRenderer() != NULL)
|
||||
if (env.getRenderer() != nullptr)
|
||||
{
|
||||
env.getRenderer()->setResolution(res);
|
||||
env.getCelestiaCore()->notifyWatchers(CelestiaCore::RenderFlagsChanged);
|
||||
|
@ -753,7 +691,7 @@ void CommandRenderPath::process(ExecutionEnvironment& env)
|
|||
{
|
||||
GLContext* context = env.getRenderer()->getGLContext();
|
||||
|
||||
if (context != NULL)
|
||||
if (context != nullptr)
|
||||
{
|
||||
context->setRenderPath(path);
|
||||
env.getCelestiaCore()->notifyWatchers(CelestiaCore::RenderFlagsChanged);
|
||||
|
@ -764,9 +702,9 @@ void CommandRenderPath::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// SplitView command
|
||||
|
||||
CommandSplitView::CommandSplitView(unsigned int _view, const string& _splitType, double _splitPos) :
|
||||
CommandSplitView::CommandSplitView(unsigned int _view, string _splitType, double _splitPos) :
|
||||
view(_view),
|
||||
splitType(_splitType),
|
||||
splitType(std::move(_splitType)),
|
||||
splitPos(_splitPos)
|
||||
{
|
||||
}
|
||||
|
@ -811,10 +749,6 @@ void CommandDeleteView::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// SingleView command
|
||||
|
||||
CommandSingleView::CommandSingleView()
|
||||
{
|
||||
}
|
||||
|
||||
void CommandSingleView::process(ExecutionEnvironment& env)
|
||||
{
|
||||
View* view = getViewByObserver(env.getCelestiaCore(), env.getSimulation()->getActiveObserver());
|
||||
|
@ -847,8 +781,8 @@ void CommandSetActiveView::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// SetRadius command
|
||||
|
||||
CommandSetRadius::CommandSetRadius(const string& _object, double _radius) :
|
||||
object(_object),
|
||||
CommandSetRadius::CommandSetRadius(string _object, double _radius) :
|
||||
object(std::move(_object)),
|
||||
radius(_radius)
|
||||
{
|
||||
}
|
||||
|
@ -856,7 +790,7 @@ CommandSetRadius::CommandSetRadius(const string& _object, double _radius) :
|
|||
void CommandSetRadius::process(ExecutionEnvironment& env)
|
||||
{
|
||||
Selection sel = env.getSimulation()->findObjectFromPath(object);
|
||||
if (sel.body() != NULL)
|
||||
if (sel.body() != nullptr)
|
||||
{
|
||||
Body* body = sel.body();
|
||||
float iradius = body->getRadius();
|
||||
|
@ -865,7 +799,7 @@ void CommandSetRadius::process(ExecutionEnvironment& env)
|
|||
body->setSemiAxes(body->getSemiAxes() * ((float) radius / iradius));
|
||||
}
|
||||
|
||||
if (body->getRings() != NULL)
|
||||
if (body->getRings() != nullptr)
|
||||
{
|
||||
RingSystem rings(0.0f, 0.0f);
|
||||
rings = *body->getRings();
|
||||
|
@ -882,8 +816,8 @@ void CommandSetRadius::process(ExecutionEnvironment& env)
|
|||
////////////////
|
||||
// SetLineColor command
|
||||
|
||||
CommandSetLineColor::CommandSetLineColor(const string& _item, Color _color) :
|
||||
item(_item),
|
||||
CommandSetLineColor::CommandSetLineColor(string _item, Color _color) :
|
||||
item(std::move(_item)),
|
||||
color(_color)
|
||||
{
|
||||
}
|
||||
|
@ -904,8 +838,8 @@ void CommandSetLineColor::process(ExecutionEnvironment& /* env */)
|
|||
////////////////
|
||||
// SetLabelColor command
|
||||
|
||||
CommandSetLabelColor::CommandSetLabelColor(const string& _item, Color _color) :
|
||||
item(_item),
|
||||
CommandSetLabelColor::CommandSetLabelColor(string _item, Color _color) :
|
||||
item(std::move(_item)),
|
||||
color(_color)
|
||||
{
|
||||
}
|
||||
|
@ -942,33 +876,30 @@ void CommandSetTextColor::process(ExecutionEnvironment& env)
|
|||
|
||||
RepeatCommand::RepeatCommand(CommandSequence* _body, int _repeatCount) :
|
||||
body(_body),
|
||||
bodyDuration(0.0),
|
||||
repeatCount(_repeatCount),
|
||||
execution(NULL)
|
||||
repeatCount(_repeatCount)
|
||||
{
|
||||
for (CommandSequence::const_iterator iter = body->begin();
|
||||
iter != body->end(); iter++)
|
||||
for (const auto b : *body)
|
||||
{
|
||||
bodyDuration += (*iter)->getDuration();
|
||||
bodyDuration += b->getDuration();
|
||||
}
|
||||
}
|
||||
|
||||
RepeatCommand::~RepeatCommand()
|
||||
{
|
||||
if (execution != NULL)
|
||||
delete execution;
|
||||
|
||||
delete execution;
|
||||
// delete body;
|
||||
}
|
||||
|
||||
void RepeatCommand::process(ExecutionEnvironment& env, double t, double dt)
|
||||
{
|
||||
double t0 = t - dt;
|
||||
int loop0 = (int) (t0 / bodyDuration);
|
||||
int loop1 = (int) (t / bodyDuration);
|
||||
auto loop0 = (int) (t0 / bodyDuration);
|
||||
auto loop1 = (int) (t / bodyDuration);
|
||||
|
||||
// TODO: This is bogus . . . should not be storing a reference to an
|
||||
// execution environment.
|
||||
if (execution == NULL)
|
||||
if (execution == nullptr)
|
||||
execution = new Execution(*body, env);
|
||||
|
||||
if (loop0 == loop1)
|
||||
|
@ -998,12 +929,12 @@ double RepeatCommand::getDuration() const
|
|||
|
||||
// ScriptImage command
|
||||
CommandScriptImage::CommandScriptImage(double _duration, float _xoffset,
|
||||
float _yoffset, float _alpha, const std::string& _filename, int _fitscreen) :
|
||||
float _yoffset, float _alpha, std::string _filename, int _fitscreen) :
|
||||
duration(_duration),
|
||||
xoffset(_xoffset),
|
||||
yoffset(_yoffset),
|
||||
alpha(_alpha),
|
||||
filename(_filename),
|
||||
filename(std::move(_filename)),
|
||||
fitscreen(_fitscreen)
|
||||
{
|
||||
}
|
||||
|
@ -1025,121 +956,86 @@ void CommandVerbosity::process(ExecutionEnvironment& env)
|
|||
}
|
||||
|
||||
|
||||
//====================================================
|
||||
// Add on by Javier Nieto from www.astrohenares.org
|
||||
//====================================================
|
||||
CommandConstellations::CommandConstellations()
|
||||
{
|
||||
numConstellations = 0;
|
||||
all = 0;
|
||||
none = 0;
|
||||
}
|
||||
///////////////
|
||||
//
|
||||
|
||||
void CommandConstellations::process(ExecutionEnvironment& env)
|
||||
{
|
||||
Universe* u = env.getSimulation()->getUniverse();
|
||||
if (u != NULL)
|
||||
if (!u)
|
||||
return;
|
||||
|
||||
AsterismList& asterisms = *u->getAsterisms();
|
||||
for (const auto ast : asterisms)
|
||||
{
|
||||
AsterismList* asterisms = u->getAsterisms();
|
||||
for (AsterismList::const_iterator iter = asterisms->begin();
|
||||
iter != asterisms->end(); iter++)
|
||||
if (flags.none)
|
||||
{
|
||||
Asterism* ast = *iter;
|
||||
if (none)
|
||||
{
|
||||
ast->setActive(0);
|
||||
}
|
||||
else if (all)
|
||||
{
|
||||
ast->setActive(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < numConstellations; i++)
|
||||
{
|
||||
if (compareIgnoringCase(constellation[i],ast->getName(false)) == 0)
|
||||
{
|
||||
ast->setActive(active[i] != 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ast->setActive(0);
|
||||
}
|
||||
else if (flags.all)
|
||||
{
|
||||
ast->setActive(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto name = ast->getName(false);
|
||||
auto it = std::find_if(constellations.begin(), constellations.end(),
|
||||
[&name](Cons& c){ return compareIgnoringCase(c.name, name) == 0; });
|
||||
|
||||
if (it != constellations.end())
|
||||
ast->setActive(it->active != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommandConstellations::setValues(string cons, int act)
|
||||
{
|
||||
int found = 0;
|
||||
for (unsigned int j = 0; j < cons.size(); j++)
|
||||
{
|
||||
if(cons[j] == '_')
|
||||
cons[j] = ' ';
|
||||
}
|
||||
|
||||
// ignore all above 99 constellations
|
||||
if (numConstellations == MAX_CONSTELLATIONS)
|
||||
if (constellations.size() == MAX_CONSTELLATIONS)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < numConstellations; i++)
|
||||
{
|
||||
if (compareIgnoringCase(constellation[i], cons) == 0 )
|
||||
{
|
||||
active[i]=act;
|
||||
found=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
std::replace(cons.begin(), cons.end(), '_', ' ');
|
||||
|
||||
if (!found)
|
||||
{
|
||||
constellation[numConstellations]=cons;
|
||||
active[numConstellations]=act;
|
||||
numConstellations++;
|
||||
}
|
||||
}
|
||||
auto it = std::find_if(constellations.begin(), constellations.end(),
|
||||
[&cons](Cons& c){ return compareIgnoringCase(c.name, cons) == 0; });
|
||||
|
||||
|
||||
CommandConstellationColor::CommandConstellationColor()
|
||||
{
|
||||
numConstellations=0;
|
||||
all=0;
|
||||
none=0;
|
||||
unset=0;
|
||||
if (it != constellations.end())
|
||||
it->active = act;
|
||||
else
|
||||
constellations.push_back({cons, act}); // If not found then add a new constellation
|
||||
}
|
||||
|
||||
|
||||
void CommandConstellationColor::process(ExecutionEnvironment& env)
|
||||
{
|
||||
Universe* u = env.getSimulation()->getUniverse();
|
||||
if (u != NULL)
|
||||
if (!u)
|
||||
return;
|
||||
|
||||
AsterismList& asterisms = *u->getAsterisms();
|
||||
for (const auto ast : asterisms)
|
||||
{
|
||||
AsterismList* asterisms = u->getAsterisms();
|
||||
for (AsterismList::const_iterator iter = asterisms->begin();
|
||||
iter != asterisms->end(); iter++)
|
||||
if (flags.none)
|
||||
{
|
||||
Asterism* ast = *iter;
|
||||
if (none)
|
||||
ast->unsetOverrideColor();
|
||||
}
|
||||
else if (flags.all)
|
||||
{
|
||||
ast->setOverrideColor(rgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto name = ast->getName(false);
|
||||
//std::vector<std::string>::iterator it;
|
||||
auto it = std::find_if(constellations.begin(), constellations.end(),
|
||||
[&name](string& c){ return compareIgnoringCase(c, name) == 0; });
|
||||
|
||||
if (it != constellations.end())
|
||||
{
|
||||
ast->unsetOverrideColor();
|
||||
}
|
||||
else if (all)
|
||||
{
|
||||
ast->setOverrideColor(rgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < numConstellations; i++)
|
||||
{
|
||||
if (compareIgnoringCase(constellation[i],ast->getName(false)) ==0 )
|
||||
{
|
||||
if(unset)
|
||||
ast->unsetOverrideColor();
|
||||
else
|
||||
ast->setOverrideColor(rgb);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flags.unset)
|
||||
ast->unsetOverrideColor();
|
||||
else
|
||||
ast->setOverrideColor(rgb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1149,43 +1045,27 @@ void CommandConstellationColor::process(ExecutionEnvironment& env)
|
|||
void CommandConstellationColor::setColor(float r, float g, float b)
|
||||
{
|
||||
rgb = Color(r, g, b);
|
||||
unset = 0;
|
||||
flags.unset = false;
|
||||
}
|
||||
|
||||
|
||||
void CommandConstellationColor::unsetColor()
|
||||
{
|
||||
unset = 1;
|
||||
flags.unset = true;
|
||||
}
|
||||
|
||||
|
||||
void CommandConstellationColor::setConstellations(string cons)
|
||||
{
|
||||
int found=0;
|
||||
for (unsigned int j = 0; j < cons.size(); j++)
|
||||
{
|
||||
if (cons[j] == '_')
|
||||
cons[j] = ' ';
|
||||
}
|
||||
|
||||
// ignore all above 99 constellations
|
||||
if (numConstellations == MAX_CONSTELLATIONS)
|
||||
return;
|
||||
if (constellations.size() == MAX_CONSTELLATIONS)
|
||||
return;
|
||||
|
||||
for (int i=0; i<numConstellations; i++)
|
||||
{
|
||||
if (compareIgnoringCase(constellation[i], cons) == 0)
|
||||
{
|
||||
found=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
std::replace(cons.begin(), cons.end(), '_', ' ');
|
||||
|
||||
if (!found)
|
||||
{
|
||||
constellation[numConstellations]=cons;
|
||||
numConstellations++;
|
||||
}
|
||||
// If not found then add a new constellation
|
||||
if (std::none_of(constellations.begin(), constellations.end(),
|
||||
[&cons](string& c){ return compareIgnoringCase(c, cons) == 0; }))
|
||||
constellations.push_back(cons);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class CommandWait : public TimedCommand
|
|||
{
|
||||
public:
|
||||
CommandWait(double _duration);
|
||||
~CommandWait();
|
||||
~CommandWait() = default;
|
||||
void process(ExecutionEnvironment&, double t, double dt);
|
||||
};
|
||||
|
||||
|
@ -69,7 +69,7 @@ class CommandSelect : public InstantaneousCommand
|
|||
{
|
||||
public:
|
||||
CommandSelect(std::string _target);
|
||||
~CommandSelect();
|
||||
~CommandSelect() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -82,7 +82,7 @@ class CommandGoto : public InstantaneousCommand
|
|||
public:
|
||||
CommandGoto(double t, double dist,
|
||||
Vec3f _up, ObserverFrame::CoordinateSystem _upFrame);
|
||||
~CommandGoto();
|
||||
~CommandGoto() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -100,7 +100,7 @@ class CommandGotoLongLat : public InstantaneousCommand
|
|||
double dist,
|
||||
float _longitude, float _latitude,
|
||||
Vec3f _up);
|
||||
~CommandGotoLongLat();
|
||||
~CommandGotoLongLat() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -117,7 +117,7 @@ class CommandGotoLocation : public InstantaneousCommand
|
|||
public:
|
||||
CommandGotoLocation(double t,
|
||||
const Point3d& translation, const Quatf& rotation);
|
||||
~CommandGotoLocation();
|
||||
~CommandGotoLocation() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -129,7 +129,7 @@ class CommandGotoLocation : public InstantaneousCommand
|
|||
class CommandSetUrl : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandSetUrl(const std::string& _url);
|
||||
CommandSetUrl(std::string _url);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -141,7 +141,7 @@ class CommandCenter : public InstantaneousCommand
|
|||
{
|
||||
public:
|
||||
CommandCenter(double t);
|
||||
~CommandCenter();
|
||||
~CommandCenter() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -152,7 +152,7 @@ class CommandCenter : public InstantaneousCommand
|
|||
class CommandFollow : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandFollow();
|
||||
CommandFollow() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -163,7 +163,7 @@ class CommandFollow : public InstantaneousCommand
|
|||
class CommandSynchronous : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandSynchronous();
|
||||
CommandSynchronous() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -174,7 +174,7 @@ class CommandSynchronous : public InstantaneousCommand
|
|||
class CommandLock : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandLock();
|
||||
CommandLock() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -185,7 +185,7 @@ class CommandLock : public InstantaneousCommand
|
|||
class CommandChase : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandChase();
|
||||
CommandChase() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -196,7 +196,7 @@ class CommandChase : public InstantaneousCommand
|
|||
class CommandTrack : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandTrack();
|
||||
CommandTrack() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -208,7 +208,7 @@ class CommandSetFrame : public InstantaneousCommand
|
|||
{
|
||||
public:
|
||||
CommandSetFrame(ObserverFrame::CoordinateSystem,
|
||||
const std::string&, const std::string&);
|
||||
std::string, std::string);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -221,7 +221,7 @@ class CommandSetFrame : public InstantaneousCommand
|
|||
class CommandSetSurface : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandSetSurface(const std::string&);
|
||||
CommandSetSurface(std::string);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -232,7 +232,7 @@ class CommandSetSurface : public InstantaneousCommand
|
|||
class CommandCancel : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandCancel();
|
||||
CommandCancel() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -243,7 +243,7 @@ class CommandCancel : public InstantaneousCommand
|
|||
class CommandExit : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandExit();
|
||||
CommandExit() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -255,7 +255,7 @@ class CommandPrint : public InstantaneousCommand
|
|||
{
|
||||
public:
|
||||
CommandPrint(std::string, int horig, int vorig, int hoff, int voff,
|
||||
double duration);
|
||||
double _duration);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -271,7 +271,7 @@ class CommandPrint : public InstantaneousCommand
|
|||
class CommandClearScreen : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandClearScreen();
|
||||
CommandClearScreen() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -304,7 +304,7 @@ class CommandSetTimeRate : public InstantaneousCommand
|
|||
class CommandChangeDistance : public TimedCommand
|
||||
{
|
||||
public:
|
||||
CommandChangeDistance(double duration, double rate);
|
||||
CommandChangeDistance(double _duration, double _rate);
|
||||
void process(ExecutionEnvironment&, double t, double dt);
|
||||
|
||||
private:
|
||||
|
@ -370,7 +370,7 @@ class CommandSetOrientation : public InstantaneousCommand
|
|||
class CommandLookBack : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandLookBack();
|
||||
CommandLookBack() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -392,32 +392,50 @@ class CommandRenderFlags : public InstantaneousCommand
|
|||
|
||||
class CommandConstellations : public InstantaneousCommand
|
||||
{
|
||||
struct Flags
|
||||
{
|
||||
bool none:1;
|
||||
bool all:1;
|
||||
};
|
||||
|
||||
public:
|
||||
CommandConstellations();
|
||||
CommandConstellations() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
void setValues(string cons, int act);
|
||||
std::string constellation[MAX_CONSTELLATIONS];
|
||||
int active[MAX_CONSTELLATIONS];
|
||||
int numConstellations;
|
||||
int all;
|
||||
int none;
|
||||
|
||||
Flags flags { false, false };
|
||||
|
||||
private:
|
||||
struct Cons
|
||||
{
|
||||
std::string name;
|
||||
int active;
|
||||
};
|
||||
std::vector<Cons> constellations;
|
||||
};
|
||||
|
||||
|
||||
class CommandConstellationColor : public InstantaneousCommand
|
||||
{
|
||||
struct Flags
|
||||
{
|
||||
bool none:1;
|
||||
bool all:1;
|
||||
bool unset:1;
|
||||
};
|
||||
|
||||
public:
|
||||
CommandConstellationColor();
|
||||
CommandConstellationColor() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
void setConstellations(string cons);
|
||||
void setColor(float r, float g, float b);
|
||||
void unsetColor();
|
||||
std::string constellation[MAX_CONSTELLATIONS];
|
||||
|
||||
Flags flags { false, false, false};
|
||||
|
||||
private:
|
||||
std::vector<std::string> constellations;
|
||||
Color rgb;
|
||||
int unset;
|
||||
int numConstellations;
|
||||
int all;
|
||||
int none;
|
||||
};
|
||||
|
||||
|
||||
|
@ -490,7 +508,7 @@ class CommandSetGalaxyLightGain : public InstantaneousCommand
|
|||
class CommandSet : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandSet(const std::string&, double);
|
||||
CommandSet(std::string, double);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -502,7 +520,7 @@ class CommandSet : public InstantaneousCommand
|
|||
class CommandPreloadTextures : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandPreloadTextures(const std::string&);
|
||||
CommandPreloadTextures(std::string);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -513,7 +531,7 @@ class CommandPreloadTextures : public InstantaneousCommand
|
|||
class CommandMark : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandMark(const std::string&, MarkerRepresentation, bool);
|
||||
CommandMark(std::string, MarkerRepresentation, bool);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -526,7 +544,7 @@ class CommandMark : public InstantaneousCommand
|
|||
class CommandUnmark : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandUnmark(const std::string&);
|
||||
CommandUnmark(std::string);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -537,7 +555,7 @@ class CommandUnmark : public InstantaneousCommand
|
|||
class CommandUnmarkAll : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandUnmarkAll();
|
||||
CommandUnmarkAll() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -548,7 +566,7 @@ class CommandUnmarkAll : public InstantaneousCommand
|
|||
class CommandCapture : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandCapture(const std::string&, const std::string&);
|
||||
CommandCapture(std::string, std::string);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -582,7 +600,7 @@ class CommandRenderPath : public InstantaneousCommand
|
|||
class CommandSplitView : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandSplitView(unsigned int, const std::string&, double);
|
||||
CommandSplitView(unsigned int, std::string, double);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -606,7 +624,7 @@ class CommandDeleteView : public InstantaneousCommand
|
|||
class CommandSingleView : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandSingleView();
|
||||
CommandSingleView() = default;
|
||||
void process(ExecutionEnvironment&);
|
||||
};
|
||||
|
||||
|
@ -625,7 +643,7 @@ class CommandSetActiveView : public InstantaneousCommand
|
|||
class CommandSetRadius : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandSetRadius(const std::string&, double);
|
||||
CommandSetRadius(std::string, double);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -637,7 +655,7 @@ class CommandSetRadius : public InstantaneousCommand
|
|||
class CommandSetLineColor : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandSetLineColor(const std::string&, Color);
|
||||
CommandSetLineColor(std::string, Color);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -649,7 +667,7 @@ class CommandSetLineColor : public InstantaneousCommand
|
|||
class CommandSetLabelColor : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandSetLabelColor(const std::string&, Color);
|
||||
CommandSetLabelColor(std::string, Color);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -681,17 +699,17 @@ class RepeatCommand : public Command
|
|||
|
||||
private:
|
||||
CommandSequence* body;
|
||||
double bodyDuration;
|
||||
double bodyDuration{ 0.0 };
|
||||
int repeatCount;
|
||||
Execution* execution;
|
||||
Execution* execution{ nullptr };
|
||||
};
|
||||
|
||||
|
||||
class CommandScriptImage : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandScriptImage(double duration, float xoffset, float yoffset,
|
||||
float alpha, const std::string&, int fitscreen);
|
||||
CommandScriptImage(double _duration, float _xoffset, float _yoffset,
|
||||
float _alpha, std::string, int _fitscreen);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
@ -706,7 +724,7 @@ class CommandScriptImage : public InstantaneousCommand
|
|||
class CommandVerbosity : public InstantaneousCommand
|
||||
{
|
||||
public:
|
||||
CommandVerbosity(int level);
|
||||
CommandVerbosity(int _level);
|
||||
void process(ExecutionEnvironment&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -28,17 +28,8 @@ static int pmod(int n, int m)
|
|||
|
||||
Console::Console(int _nRows, int _nColumns) :
|
||||
ostream(&sbuf),
|
||||
text(NULL),
|
||||
nRows(_nRows),
|
||||
nColumns(_nColumns),
|
||||
row(0),
|
||||
column(0),
|
||||
windowRow(0),
|
||||
windowHeight(10),
|
||||
xscale(1),
|
||||
yscale(1),
|
||||
font(NULL),
|
||||
autoScroll(true)
|
||||
nColumns(_nColumns)
|
||||
{
|
||||
sbuf.setConsole(this);
|
||||
text = new wchar_t[(nColumns + 1) * nRows];
|
||||
|
@ -49,8 +40,7 @@ Console::Console(int _nRows, int _nColumns) :
|
|||
|
||||
Console::~Console()
|
||||
{
|
||||
if (text != NULL)
|
||||
delete[] text;
|
||||
delete[] text;
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,8 +51,8 @@ Console::~Console()
|
|||
*/
|
||||
bool Console::setRowCount(int _nRows)
|
||||
{
|
||||
wchar_t* newText = new wchar_t[(nColumns + 1) * _nRows];
|
||||
if (newText == NULL)
|
||||
auto* newText = new wchar_t[(nColumns + 1) * _nRows];
|
||||
if (newText == nullptr)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < _nRows; i++)
|
||||
|
@ -109,7 +99,7 @@ void Console::end()
|
|||
|
||||
void Console::render(int rowHeight)
|
||||
{
|
||||
if (font == NULL)
|
||||
if (font == nullptr)
|
||||
return;
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
@ -146,9 +136,7 @@ void Console::setScale(int w, int h)
|
|||
void Console::setFont(TextureFont* f)
|
||||
{
|
||||
if (f != font)
|
||||
{
|
||||
font = f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -265,7 +253,7 @@ void ConsoleStreamBuf::setConsole(Console* c)
|
|||
|
||||
int ConsoleStreamBuf::overflow(int c)
|
||||
{
|
||||
if (console != NULL)
|
||||
if (console != nullptr)
|
||||
{
|
||||
switch (decodeState)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ class Console;
|
|||
class ConsoleStreamBuf : public std::streambuf
|
||||
{
|
||||
public:
|
||||
ConsoleStreamBuf() : console(NULL) { setbuf(0, 0); };
|
||||
ConsoleStreamBuf() : console(nullptr) { setbuf(0, 0); };
|
||||
|
||||
void setConsole(Console*);
|
||||
|
||||
|
@ -73,23 +73,23 @@ class Console : public std::ostream
|
|||
int getWidth() const;
|
||||
|
||||
private:
|
||||
wchar_t* text;
|
||||
wchar_t* text{ nullptr };
|
||||
int nRows;
|
||||
int nColumns;
|
||||
int row;
|
||||
int column;
|
||||
int row{ 0 };
|
||||
int column{ 0 };
|
||||
|
||||
int windowRow;
|
||||
int windowRow{ 0 };
|
||||
|
||||
int windowHeight;
|
||||
int windowHeight{ 10 };
|
||||
|
||||
int xscale;
|
||||
int yscale;
|
||||
TextureFont* font;
|
||||
int xscale{ 1 };
|
||||
int yscale{ 1 };
|
||||
TextureFont* font{ nullptr };
|
||||
|
||||
ConsoleStreamBuf sbuf;
|
||||
|
||||
bool autoScroll;
|
||||
bool autoScroll{ true };
|
||||
};
|
||||
|
||||
#endif // _CELENGINE_CONSOLE_H_
|
||||
|
|
|
@ -112,32 +112,32 @@ static struct Constellation_s constellationInfo[] = {
|
|||
{ "Vulpecula", "Vulpeculae", "Vul" }
|
||||
};
|
||||
|
||||
static Constellation **constellations = NULL;
|
||||
static Constellation **constellations = nullptr;
|
||||
|
||||
|
||||
Constellation::Constellation(const char *_name, const char *_genitive, const char *_abbrev)
|
||||
Constellation::Constellation(const char *_name, const char *_genitive, const char *_abbrev) :
|
||||
name(_name),
|
||||
genitive(_genitive),
|
||||
abbrev(_abbrev)
|
||||
{
|
||||
name = string(_name);
|
||||
genitive = string(_genitive);
|
||||
abbrev = string(_abbrev);
|
||||
}
|
||||
|
||||
Constellation* Constellation::getConstellation(unsigned int n)
|
||||
{
|
||||
if (constellations == NULL)
|
||||
if (constellations == nullptr)
|
||||
initialize();
|
||||
|
||||
if (constellations == NULL ||
|
||||
if (constellations == nullptr ||
|
||||
n >= sizeof(constellationInfo) / sizeof(constellationInfo[0]))
|
||||
return NULL;
|
||||
else
|
||||
return constellations[n];
|
||||
return nullptr;
|
||||
|
||||
return constellations[n];
|
||||
}
|
||||
|
||||
Constellation* Constellation::getConstellation(const string& name)
|
||||
{
|
||||
if (constellations == NULL)
|
||||
initialize();
|
||||
if (constellations == nullptr)
|
||||
initialize();
|
||||
|
||||
for (unsigned int i = 0;
|
||||
i < sizeof(constellationInfo) / sizeof(constellationInfo[0]);
|
||||
|
@ -151,20 +151,20 @@ Constellation* Constellation::getConstellation(const string& name)
|
|||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
string Constellation::getName()
|
||||
const string Constellation::getName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
string Constellation::getGenitive()
|
||||
const string Constellation::getGenitive() const
|
||||
{
|
||||
return genitive;
|
||||
}
|
||||
|
||||
string Constellation::getAbbreviation()
|
||||
const string Constellation::getAbbreviation() const
|
||||
{
|
||||
return abbrev;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ void Constellation::initialize()
|
|||
int nConstellations = sizeof(constellationInfo) / sizeof(constellationInfo[0]);
|
||||
constellations = new Constellation* [nConstellations];
|
||||
|
||||
if (constellations != NULL)
|
||||
if (constellations != nullptr)
|
||||
{
|
||||
for (int i = 0; i < nConstellations; i++)
|
||||
{
|
||||
|
|
|
@ -18,9 +18,9 @@ public:
|
|||
static Constellation *getConstellation(unsigned int);
|
||||
static Constellation *getConstellation(const std::string&);
|
||||
|
||||
std::string getName();
|
||||
std::string getGenitive();
|
||||
std::string getAbbreviation();
|
||||
const std::string getName() const;
|
||||
const std::string getGenitive() const;
|
||||
const std::string getAbbreviation() const;
|
||||
|
||||
private:
|
||||
Constellation(const char *_name, const char *_genitive, const char *_abbrev);
|
||||
|
|
|
@ -85,11 +85,11 @@ static uint32 FourCC(const char* s)
|
|||
|
||||
Image* LoadDDSImage(const string& filename)
|
||||
{
|
||||
ifstream in(filename.c_str(), ios::in | ios::binary);
|
||||
ifstream in(filename, ios::in | ios::binary);
|
||||
if (!in.good())
|
||||
{
|
||||
DPRINTF(0, "Error opening DDS texture file %s.\n", filename.c_str());
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char header[4];
|
||||
|
@ -98,7 +98,7 @@ Image* LoadDDSImage(const string& filename)
|
|||
header[2] != 'S' || header[3] != ' ')
|
||||
{
|
||||
DPRINTF(0, "DDS texture file %s has bad header.\n", filename.c_str());
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DDSurfaceDesc ddsd;
|
||||
|
@ -178,7 +178,7 @@ Image* LoadDDSImage(const string& filename)
|
|||
{
|
||||
DPRINTF(0, "Unsupported format for DDS texture file %s.\n",
|
||||
filename.c_str());
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If we have a compressed format, give up if S3 texture compression
|
||||
|
@ -188,7 +188,7 @@ Image* LoadDDSImage(const string& filename)
|
|||
format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)
|
||||
{
|
||||
if (!GLEW_EXT_texture_compression_s3tc)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// TODO: Verify that the reported texture size matches the amount of
|
||||
|
@ -198,8 +198,8 @@ Image* LoadDDSImage(const string& filename)
|
|||
(int) ddsd.width,
|
||||
(int) ddsd.height,
|
||||
max(ddsd.mipMapLevels, 1u));
|
||||
if (img == NULL)
|
||||
return NULL;
|
||||
if (img == nullptr)
|
||||
return nullptr;
|
||||
|
||||
in.read(reinterpret_cast<char*>(img->getPixels()), img->getSize());
|
||||
if (!in.eof() && !in.good())
|
||||
|
@ -207,7 +207,7 @@ Image* LoadDDSImage(const string& filename)
|
|||
DPRINTF(0, "Failed reading data from DDS texture file %s.\n",
|
||||
filename.c_str());
|
||||
delete img;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// of the License, or (at your option) any later version.
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
#include "celestia.h"
|
||||
#include <cassert>
|
||||
#include "astro.h"
|
||||
|
@ -27,25 +27,6 @@ using namespace Eigen;
|
|||
using namespace std;
|
||||
|
||||
|
||||
const float DSO_DEFAULT_ABS_MAGNITUDE = -1000.0f;
|
||||
|
||||
|
||||
DeepSkyObject::DeepSkyObject() :
|
||||
catalogNumber(InvalidCatalogNumber),
|
||||
position(0, 0, 0),
|
||||
orientation(Quaternionf::Identity()),
|
||||
radius(1),
|
||||
absMag(DSO_DEFAULT_ABS_MAGNITUDE),
|
||||
infoURL(NULL),
|
||||
visible(true),
|
||||
clickable(true)
|
||||
{
|
||||
}
|
||||
|
||||
DeepSkyObject::~DeepSkyObject()
|
||||
{
|
||||
}
|
||||
|
||||
void DeepSkyObject::setCatalogNumber(uint32 n)
|
||||
{
|
||||
catalogNumber = n;
|
||||
|
@ -95,7 +76,7 @@ size_t DeepSkyObject::getDescription(char* buf, size_t bufLength) const
|
|||
|
||||
string DeepSkyObject::getInfoURL() const
|
||||
{
|
||||
if (infoURL == NULL)
|
||||
if (infoURL == nullptr)
|
||||
return "";
|
||||
else
|
||||
return *infoURL;
|
||||
|
@ -103,7 +84,7 @@ string DeepSkyObject::getInfoURL() const
|
|||
|
||||
void DeepSkyObject::setInfoURL(const string& s)
|
||||
{
|
||||
if (infoURL == NULL)
|
||||
if (infoURL == nullptr)
|
||||
infoURL = new string(s);
|
||||
else
|
||||
*infoURL = s;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <Eigen/Core>
|
||||
#include <Eigen/Geometry>
|
||||
|
||||
extern const float DSO_DEFAULT_ABS_MAGNITUDE;
|
||||
const float DSO_DEFAULT_ABS_MAGNITUDE = -1000.0f;
|
||||
|
||||
class Nebula;
|
||||
class Galaxy;
|
||||
|
@ -32,8 +32,8 @@ class DeepSkyObject
|
|||
public:
|
||||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||
|
||||
DeepSkyObject();
|
||||
virtual ~DeepSkyObject();
|
||||
DeepSkyObject() = default;
|
||||
virtual ~DeepSkyObject() = default;
|
||||
|
||||
inline uint32 getCatalogNumber() const
|
||||
{
|
||||
|
@ -100,15 +100,15 @@ class DeepSkyObject
|
|||
};
|
||||
|
||||
private:
|
||||
uint32 catalogNumber;
|
||||
Eigen::Vector3d position;
|
||||
Eigen::Quaternionf orientation;
|
||||
float radius;
|
||||
float absMag;
|
||||
std::string* infoURL;
|
||||
uint32 catalogNumber{ InvalidCatalogNumber };
|
||||
Eigen::Vector3d position{ 0, 0, 0 };
|
||||
Eigen::Quaternionf orientation{ Eigen::Quaternionf::Identity() };
|
||||
float radius{ 1 };
|
||||
float absMag{ DSO_DEFAULT_ABS_MAGNITUDE } ;
|
||||
std::string* infoURL{ nullptr };
|
||||
|
||||
bool visible : 1;
|
||||
bool clickable : 1;
|
||||
bool visible { true };
|
||||
bool clickable { true };
|
||||
};
|
||||
|
||||
typedef std::vector<DeepSkyObject*> DeepSkyCatalog;
|
||||
|
|
|
@ -11,15 +11,14 @@
|
|||
|
||||
|
||||
DisplacementMap::DisplacementMap(int w, int h) :
|
||||
width(w), height(h), disp(NULL)
|
||||
width(w), height(h), disp(nullptr)
|
||||
{
|
||||
disp = new float[width * height];
|
||||
}
|
||||
|
||||
DisplacementMap::~DisplacementMap()
|
||||
{
|
||||
if (disp != NULL)
|
||||
delete[] disp;
|
||||
delete[] disp;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class DisplacementMap
|
|||
int getHeight() const { return height; };
|
||||
inline float getDisplacement(int x, int y) const;
|
||||
inline void setDisplacement(int x, int y, float d);
|
||||
void generate(DisplacementMapFunc func, void* info = NULL);
|
||||
void generate(DisplacementMapFunc func, void* info = nullptr);
|
||||
void clear();
|
||||
|
||||
private:
|
||||
|
|
|
@ -55,7 +55,7 @@ struct PtrCatalogNumberOrderingPredicate
|
|||
{
|
||||
int unused;
|
||||
|
||||
PtrCatalogNumberOrderingPredicate() {};
|
||||
PtrCatalogNumberOrderingPredicate() = default;;
|
||||
|
||||
bool operator()(const DeepSkyObject* const & dso0, const DeepSkyObject* const & dso1) const
|
||||
{
|
||||
|
@ -64,26 +64,10 @@ struct PtrCatalogNumberOrderingPredicate
|
|||
};
|
||||
|
||||
|
||||
DSODatabase::DSODatabase():
|
||||
nDSOs (0),
|
||||
capacity (0),
|
||||
DSOs (NULL),
|
||||
namesDB (NULL),
|
||||
catalogNumberIndex (NULL),
|
||||
octreeRoot (NULL),
|
||||
nextAutoCatalogNumber(0xfffffffe),
|
||||
avgAbsMag (0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DSODatabase::~DSODatabase()
|
||||
{
|
||||
if (DSOs != NULL)
|
||||
delete [] DSOs;
|
||||
|
||||
if (catalogNumberIndex != NULL)
|
||||
delete [] catalogNumberIndex;
|
||||
delete [] DSOs;
|
||||
delete [] catalogNumberIndex;
|
||||
}
|
||||
|
||||
|
||||
|
@ -100,23 +84,23 @@ DeepSkyObject* DSODatabase::find(const uint32 catalogNumber) const
|
|||
if (dso != catalogNumberIndex + nDSOs && (*dso)->getCatalogNumber() == catalogNumber)
|
||||
return *dso;
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
DeepSkyObject* DSODatabase::find(const string& name) const
|
||||
{
|
||||
if (name.empty())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (namesDB != NULL)
|
||||
if (namesDB != nullptr)
|
||||
{
|
||||
uint32 catalogNumber = namesDB->findCatalogNumberByName(name);
|
||||
if (catalogNumber != DeepSkyObject::InvalidCatalogNumber)
|
||||
return find(catalogNumber);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,7 +109,7 @@ vector<string> DSODatabase::getCompletion(const string& name) const
|
|||
vector<string> completion;
|
||||
|
||||
// only named DSOs are supported by completion.
|
||||
if (!name.empty() && namesDB != NULL)
|
||||
if (!name.empty() && namesDB != nullptr)
|
||||
return namesDB->getCompletion(name);
|
||||
else
|
||||
return completion;
|
||||
|
@ -136,7 +120,7 @@ string DSODatabase::getDSOName(const DeepSkyObject* const & dso, bool i18n) cons
|
|||
{
|
||||
uint32 catalogNumber = dso->getCatalogNumber();
|
||||
|
||||
if (namesDB != NULL)
|
||||
if (namesDB != nullptr)
|
||||
{
|
||||
DSONameDatabase::NumberIndex::const_iterator iter = namesDB->getFirstNameIter(catalogNumber);
|
||||
if (iter != namesDB->getFinalNameIter() && iter->first == catalogNumber)
|
||||
|
@ -273,7 +257,7 @@ bool DSODatabase::load(istream& in, const string& resourcePath)
|
|||
objName = tokenizer.getStringValue();
|
||||
|
||||
Value* objParamsValue = parser.readValue();
|
||||
if (objParamsValue == NULL ||
|
||||
if (objParamsValue == nullptr ||
|
||||
objParamsValue->getType() != Value::HashType)
|
||||
{
|
||||
DPRINTF(0, "Error parsing deep sky catalog entry %s\n", objName.c_str());
|
||||
|
@ -281,9 +265,9 @@ bool DSODatabase::load(istream& in, const string& resourcePath)
|
|||
}
|
||||
|
||||
Hash* objParams = objParamsValue->getHash();
|
||||
assert(objParams != NULL);
|
||||
assert(objParams != nullptr);
|
||||
|
||||
DeepSkyObject* obj = NULL;
|
||||
DeepSkyObject* obj = nullptr;
|
||||
if (compareIgnoringCase(objType, "Galaxy") == 0)
|
||||
obj = new Galaxy();
|
||||
else if (compareIgnoringCase(objType, "Globular") == 0)
|
||||
|
@ -293,7 +277,7 @@ bool DSODatabase::load(istream& in, const string& resourcePath)
|
|||
else if (compareIgnoringCase(objType, "OpenCluster") == 0)
|
||||
obj = new OpenCluster();
|
||||
|
||||
if (obj != NULL && obj->load(objParams, resourcePath))
|
||||
if (obj != nullptr && obj->load(objParams, resourcePath))
|
||||
{
|
||||
delete objParamsValue;
|
||||
|
||||
|
@ -311,13 +295,13 @@ bool DSODatabase::load(istream& in, const string& resourcePath)
|
|||
capacity = 100;
|
||||
|
||||
DeepSkyObject** newDSOs = new DeepSkyObject*[capacity];
|
||||
if (newDSOs == NULL)
|
||||
if (newDSOs == nullptr)
|
||||
{
|
||||
DPRINTF(0, "Out of memory!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DSOs != NULL)
|
||||
if (DSOs != nullptr)
|
||||
{
|
||||
copy(DSOs, DSOs + nDSOs, newDSOs);
|
||||
delete[] DSOs;
|
||||
|
@ -329,7 +313,7 @@ bool DSODatabase::load(istream& in, const string& resourcePath)
|
|||
|
||||
obj->setCatalogNumber(objCatalogNumber);
|
||||
|
||||
if (namesDB != NULL && !objName.empty())
|
||||
if (namesDB != nullptr && !objName.empty())
|
||||
{
|
||||
// List of names will replace any that already exist for
|
||||
// this DSO.
|
||||
|
@ -448,7 +432,7 @@ void DSODatabase::calcAvgAbsMag()
|
|||
void DSODatabase::buildIndexes()
|
||||
{
|
||||
// This should only be called once for the database
|
||||
// assert(catalogNumberIndexes[0] == NULL);
|
||||
// assert(catalogNumberIndexes[0] == nullptr);
|
||||
|
||||
DPRINTF(1, "Building catalog number indexes . . .\n");
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ extern const float DSO_OCTREE_ROOT_SIZE;
|
|||
class DSODatabase
|
||||
{
|
||||
public:
|
||||
DSODatabase();
|
||||
DSODatabase() = default;
|
||||
~DSODatabase();
|
||||
|
||||
|
||||
|
@ -41,14 +41,14 @@ class DSODatabase
|
|||
|
||||
std::vector<std::string> getCompletion(const std::string&) const;
|
||||
|
||||
void findVisibleDSOs(DSOHandler& dsoHandler,
|
||||
void findVisibleDSOs(DSOHandler& dsoHandler,
|
||||
const Eigen::Vector3d& obsPosition,
|
||||
const Eigen::Quaternionf& obsOrientation,
|
||||
float fovY,
|
||||
float aspectRatio,
|
||||
float limitingMag) const;
|
||||
|
||||
void findCloseDSOs(DSOHandler& dsoHandler,
|
||||
void findCloseDSOs(DSOHandler& dsoHandler,
|
||||
const Eigen::Vector3d& obsPosition,
|
||||
float radius) const;
|
||||
|
||||
|
@ -73,15 +73,15 @@ private:
|
|||
void buildOctree();
|
||||
void calcAvgAbsMag();
|
||||
|
||||
int nDSOs;
|
||||
int capacity;
|
||||
DeepSkyObject** DSOs;
|
||||
DSONameDatabase* namesDB;
|
||||
DeepSkyObject** catalogNumberIndex;
|
||||
DSOOctree* octreeRoot;
|
||||
uint32 nextAutoCatalogNumber;
|
||||
int nDSOs{ 0 };
|
||||
int capacity{ 0 };
|
||||
DeepSkyObject** DSOs{ nullptr };
|
||||
DSONameDatabase* namesDB{ nullptr };
|
||||
DeepSkyObject** catalogNumberIndex{ nullptr };
|
||||
DSOOctree* octreeRoot{ nullptr };
|
||||
uint32 nextAutoCatalogNumber{ 0xfffffffe };
|
||||
|
||||
double avgAbsMag;
|
||||
double avgAbsMag{ 0.0 };
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ bool dsoAbsoluteMagnitudePredicate(DeepSkyObject* const & _dso, const float absM
|
|||
}
|
||||
|
||||
|
||||
bool dsoStraddlesNodesPredicate(const Vector3d& cellCenterPos, DeepSkyObject* const & _dso, const float)
|
||||
bool dsoStraddlesNodesPredicate(const Vector3d& cellCenterPos, DeepSkyObject* const & _dso, const float /*unused*/)
|
||||
{
|
||||
//checks if this dso's radius straddles child nodes
|
||||
float dsoRadius = _dso->getBoundingSphereRadius();
|
||||
|
@ -126,7 +126,7 @@ void DSOOctree::processVisibleObjects(DSOHandler& processor,
|
|||
if (minDistance <= 0.0 || astro::absToAppMag((double) exclusionFactor, minDistance) <= limitingFactor)
|
||||
{
|
||||
// Recurse into the child nodes
|
||||
if (_children != NULL)
|
||||
if (_children != nullptr)
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
|
@ -176,7 +176,7 @@ void DSOOctree::processCloseObjects(DSOHandler& processor,
|
|||
}
|
||||
|
||||
// Recurse into the child nodes
|
||||
if (_children != NULL)
|
||||
if (_children != nullptr)
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
|
|
|
@ -29,38 +29,38 @@ unsigned int fp::texSpecularAlpha = 0;
|
|||
class FragmentProcessorNV : public FragmentProcessor
|
||||
{
|
||||
public:
|
||||
FragmentProcessorNV();
|
||||
virtual ~FragmentProcessorNV();
|
||||
FragmentProcessorNV() = default;
|
||||
~FragmentProcessorNV() override = default;
|
||||
|
||||
virtual void enable();
|
||||
virtual void disable();
|
||||
virtual void use(unsigned int);
|
||||
virtual void parameter(fp::Parameter, float, float, float, float);
|
||||
virtual void parameter(fp::Parameter, const float*);
|
||||
void enable() override;
|
||||
void disable() override;
|
||||
void use(unsigned int /*prog*/) override;
|
||||
void parameter(fp::Parameter /*param*/, float /*x*/, float /*y*/, float /*z*/, float /*w*/) override;
|
||||
void parameter(fp::Parameter /*param*/, const float* /*fv*/) override;
|
||||
};
|
||||
|
||||
class FragmentProcessorARB : public FragmentProcessor
|
||||
{
|
||||
public:
|
||||
FragmentProcessorARB();
|
||||
virtual ~FragmentProcessorARB();
|
||||
FragmentProcessorARB() = default;
|
||||
~FragmentProcessorARB() override = default;
|
||||
|
||||
virtual void enable();
|
||||
virtual void disable();
|
||||
virtual void use(unsigned int);
|
||||
virtual void parameter(fp::Parameter, float, float, float, float);
|
||||
virtual void parameter(fp::Parameter, const float*);
|
||||
void enable() override;
|
||||
void disable() override;
|
||||
void use(unsigned int /*unused*/) override;
|
||||
void parameter(fp::Parameter /*unused*/, float /*unused*/, float /*unused*/, float /*unused*/, float /*unused*/) override;
|
||||
void parameter(fp::Parameter /*unused*/, const float* /*unused*/) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
static string* ReadTextFromFile(const string& filename)
|
||||
{
|
||||
ifstream textFile(filename.c_str(), ios::in);
|
||||
ifstream textFile(filename, ios::in);
|
||||
if (!textFile.good())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
string* s = new string();
|
||||
auto* s = new string();
|
||||
|
||||
char c;
|
||||
while (textFile.get(c))
|
||||
|
@ -92,7 +92,7 @@ static bool LoadNvFragmentProgram(const string& filename, unsigned int& id)
|
|||
cout << _("Loading NV fragment program: ") << filename << '\n';
|
||||
|
||||
string* source = ReadTextFromFile(filename);
|
||||
if (source == NULL)
|
||||
if (source == nullptr)
|
||||
{
|
||||
cout << _("Error loading NV fragment program: ") << filename << '\n';
|
||||
return false;
|
||||
|
@ -124,19 +124,19 @@ FragmentProcessor* fp::initNV()
|
|||
{
|
||||
cout << _("Initializing NV fragment programs . . .\n");
|
||||
if (!LoadNvFragmentProgram("shaders/shadow_on_rings_nv.fp", sphereShadowOnRings))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (!LoadNvFragmentProgram("shaders/eclipse1_nv.fp", eclipseShadow1))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (!LoadNvFragmentProgram("shaders/eclipse2_nv.fp", eclipseShadow2))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (!LoadNvFragmentProgram("shaders/diffuse_nv.fp", texDiffuse))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (!LoadNvFragmentProgram("shaders/bumpdiffuse_nv.fp", texDiffuseBump))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (!LoadNvFragmentProgram("shaders/texphong_nv.fp", texSpecular))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (!LoadNvFragmentProgram("shaders/texphong_alpha_nv.fp", texSpecularAlpha))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
cout << _("All NV fragment programs loaded successfully.\n");
|
||||
|
||||
|
@ -152,14 +152,6 @@ FragmentProcessor* fp::initARB()
|
|||
}
|
||||
|
||||
|
||||
FragmentProcessor::FragmentProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
FragmentProcessor::~FragmentProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
void FragmentProcessor::parameter(fp::Parameter param, const Eigen::Vector3f& v)
|
||||
{
|
||||
parameter(param, v.x(), v.y(), v.z(), 0.0f);
|
||||
|
@ -179,14 +171,6 @@ void FragmentProcessor::parameter(fp::Parameter param, const Color& c)
|
|||
|
||||
// FragmentProcessorNV implementation
|
||||
|
||||
FragmentProcessorNV::FragmentProcessorNV()
|
||||
{
|
||||
}
|
||||
|
||||
FragmentProcessorNV::~FragmentProcessorNV()
|
||||
{
|
||||
}
|
||||
|
||||
void FragmentProcessorNV::enable()
|
||||
{
|
||||
glEnable(GL_FRAGMENT_PROGRAM_NV);
|
||||
|
@ -217,14 +201,6 @@ void FragmentProcessorNV::parameter(fp::Parameter param, const float* fv)
|
|||
|
||||
// FragmentProcessorARB implementation
|
||||
|
||||
FragmentProcessorARB::FragmentProcessorARB()
|
||||
{
|
||||
}
|
||||
|
||||
FragmentProcessorARB::~FragmentProcessorARB()
|
||||
{
|
||||
}
|
||||
|
||||
void FragmentProcessorARB::enable()
|
||||
{
|
||||
//glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
|
|
@ -58,8 +58,8 @@ namespace fp
|
|||
class FragmentProcessor
|
||||
{
|
||||
public:
|
||||
FragmentProcessor();
|
||||
virtual ~FragmentProcessor();
|
||||
FragmentProcessor() = default;
|
||||
virtual ~FragmentProcessor() = default;
|
||||
|
||||
virtual void enable() = 0;
|
||||
virtual void disable() = 0;
|
||||
|
|
|
@ -199,10 +199,10 @@ getFrameDepth(const Selection& sel, unsigned int depth, unsigned int maxDepth,
|
|||
return depth;
|
||||
|
||||
Body* body = sel.body();
|
||||
if (sel.location() != NULL)
|
||||
if (sel.location() != nullptr)
|
||||
body = sel.location()->getParentBody();
|
||||
|
||||
if (body == NULL)
|
||||
if (body == nullptr)
|
||||
{
|
||||
return depth;
|
||||
}
|
||||
|
@ -210,14 +210,14 @@ getFrameDepth(const Selection& sel, unsigned int depth, unsigned int maxDepth,
|
|||
unsigned int orbitFrameDepth = depth;
|
||||
unsigned int bodyFrameDepth = depth;
|
||||
// TODO: need to check /all/ orbit frames of body
|
||||
if (body->getOrbitFrame(0.0) != NULL && frameType == ReferenceFrame::PositionFrame)
|
||||
if (body->getOrbitFrame(0.0) != nullptr && frameType == ReferenceFrame::PositionFrame)
|
||||
{
|
||||
orbitFrameDepth = body->getOrbitFrame(0.0)->nestingDepth(depth + 1, maxDepth, frameType);
|
||||
if (orbitFrameDepth > maxDepth)
|
||||
return orbitFrameDepth;
|
||||
}
|
||||
|
||||
if (body->getBodyFrame(0.0) != NULL && frameType == ReferenceFrame::OrientationFrame)
|
||||
if (body->getBodyFrame(0.0) != nullptr && frameType == ReferenceFrame::OrientationFrame)
|
||||
{
|
||||
bodyFrameDepth = body->getBodyFrame(0.0)->nestingDepth(depth + 1, maxDepth, frameType);
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ BodyMeanEquatorFrame::getAngularVelocity(double tjd) const
|
|||
}
|
||||
else
|
||||
{
|
||||
if (equatorObject.body() != NULL)
|
||||
if (equatorObject.body() != nullptr)
|
||||
{
|
||||
return equatorObject.body()->getBodyFrame(tjd)->getAngularVelocity(tjd);
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ BodyMeanEquatorFrame::isInertial() const
|
|||
// Although the mean equator of an object may vary slightly due to precession,
|
||||
// treat it as an inertial frame as long as the body frame of the object is
|
||||
// also inertial.
|
||||
if (equatorObject.body() != NULL)
|
||||
if (equatorObject.body() != nullptr)
|
||||
{
|
||||
// TIMELINE-TODO: isInertial must take a time argument.
|
||||
return equatorObject.body()->getBodyFrame(0.0)->isInertial();
|
||||
|
@ -716,7 +716,7 @@ FrameVector::FrameVector(const FrameVector& fv) :
|
|||
vec(fv.vec),
|
||||
frame(fv.frame)
|
||||
{
|
||||
if (frame != NULL)
|
||||
if (frame != nullptr)
|
||||
frame->addRef();
|
||||
}
|
||||
|
||||
|
@ -730,10 +730,10 @@ FrameVector::operator=(const FrameVector& fv)
|
|||
target = fv.target;
|
||||
vec = fv.vec;
|
||||
|
||||
if (frame != NULL)
|
||||
if (frame != nullptr)
|
||||
frame->release();
|
||||
frame = fv.frame;
|
||||
if (frame != NULL)
|
||||
if (frame != nullptr)
|
||||
frame->addRef();
|
||||
|
||||
return *this;
|
||||
|
@ -746,14 +746,14 @@ FrameVector::FrameVector(FrameVectorType t) :
|
|||
observer(),
|
||||
target(),
|
||||
vec(0.0, 0.0, 0.0),
|
||||
frame(NULL)
|
||||
frame(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FrameVector::~FrameVector()
|
||||
{
|
||||
if (frame != NULL)
|
||||
if (frame != nullptr)
|
||||
frame->release();
|
||||
}
|
||||
|
||||
|
@ -789,7 +789,7 @@ FrameVector::createConstantVector(const Vector3d& _vec,
|
|||
FrameVector fv(ConstantVector);
|
||||
fv.vec = _vec;
|
||||
fv.frame = _frame;
|
||||
if (fv.frame != NULL)
|
||||
if (fv.frame != nullptr)
|
||||
fv.frame->addRef();
|
||||
return fv;
|
||||
}
|
||||
|
@ -815,7 +815,7 @@ FrameVector::direction(double tjd) const
|
|||
break;
|
||||
|
||||
case ConstantVector:
|
||||
if (frame == NULL)
|
||||
if (frame == nullptr)
|
||||
v = vec;
|
||||
else
|
||||
v = frame->getOrientation(tjd).conjugate() * vec;
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
*/
|
||||
FrameTree::FrameTree(Star* star) :
|
||||
starParent(star),
|
||||
bodyParent(NULL),
|
||||
bodyParent(nullptr),
|
||||
m_changed(true),
|
||||
defaultFrame(NULL)
|
||||
defaultFrame(nullptr)
|
||||
{
|
||||
// Default frame for a star is J2000 ecliptical, centered
|
||||
// on the star.
|
||||
|
@ -56,10 +56,10 @@ FrameTree::FrameTree(Star* star) :
|
|||
/*! Create a frame tree associated with a planet or other solar system body.
|
||||
*/
|
||||
FrameTree::FrameTree(Body* body) :
|
||||
starParent(NULL),
|
||||
starParent(nullptr),
|
||||
bodyParent(body),
|
||||
m_changed(true),
|
||||
defaultFrame(NULL)
|
||||
defaultFrame(nullptr)
|
||||
{
|
||||
// Default frame for a solar system body is the mean equatorial frame of the body.
|
||||
defaultFrame = new BodyMeanEquatorFrame(Selection(body), Selection(body));
|
||||
|
@ -92,7 +92,7 @@ FrameTree::markChanged()
|
|||
if (!m_changed)
|
||||
{
|
||||
m_changed = true;
|
||||
if (bodyParent != NULL)
|
||||
if (bodyParent != nullptr)
|
||||
bodyParent->markChanged();
|
||||
}
|
||||
}
|
||||
|
@ -108,11 +108,8 @@ FrameTree::markUpdated()
|
|||
if (m_changed)
|
||||
{
|
||||
m_changed = false;
|
||||
for (vector<TimelinePhase*>::iterator iter = children.begin();
|
||||
iter != children.end(); iter++)
|
||||
{
|
||||
(*iter)->body()->markUpdated();
|
||||
}
|
||||
for (const auto child : children)
|
||||
child->body()->markUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,10 +130,8 @@ FrameTree::recomputeBoundingSphere()
|
|||
m_containsSecondaryIlluminators = false;
|
||||
m_childClassMask = 0;
|
||||
|
||||
for (vector<TimelinePhase*>::iterator iter = children.begin();
|
||||
iter != children.end(); iter++)
|
||||
for (const auto phase : children)
|
||||
{
|
||||
TimelinePhase* phase = *iter;
|
||||
double bodyRadius = phase->body()->getRadius();
|
||||
double r = phase->body()->getCullingRadius() + phase->orbit()->getBoundingRadius();
|
||||
m_maxChildRadius = max(m_maxChildRadius, bodyRadius);
|
||||
|
@ -144,7 +139,7 @@ FrameTree::recomputeBoundingSphere()
|
|||
m_childClassMask |= phase->body()->getClassification();
|
||||
|
||||
FrameTree* tree = phase->body()->getFrameTree();
|
||||
if (tree != NULL)
|
||||
if (tree != nullptr)
|
||||
{
|
||||
tree->recomputeBoundingSphere();
|
||||
r += tree->m_boundingSphereRadius;
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
~FrameTree();
|
||||
|
||||
/*! Return the star that this tree is associated with; it will be
|
||||
* NULL for frame trees associated with solar system bodies.
|
||||
* nullptr for frame trees associated with solar system bodies.
|
||||
*/
|
||||
Star* getStar() const
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
bool isRoot() const
|
||||
{
|
||||
return bodyParent == NULL;
|
||||
return bodyParent == nullptr;
|
||||
}
|
||||
|
||||
bool updateRequired() const
|
||||
|
|
|
@ -34,11 +34,11 @@ static const unsigned int GALAXY_POINTS = 3500;
|
|||
|
||||
static bool formsInitialized = false;
|
||||
|
||||
static GalacticForm** spiralForms = NULL;
|
||||
static GalacticForm** ellipticalForms = NULL;
|
||||
static GalacticForm* irregularForm = NULL;
|
||||
static GalacticForm** spiralForms = nullptr;
|
||||
static GalacticForm** ellipticalForms = nullptr;
|
||||
static GalacticForm* irregularForm = nullptr;
|
||||
|
||||
static Texture* galaxyTex = NULL;
|
||||
static Texture* galaxyTex = nullptr;
|
||||
|
||||
static void InitializeForms();
|
||||
static GalacticForm* buildGalacticForms(const std::string& filename);
|
||||
|
@ -91,7 +91,7 @@ static void GalaxyTextureEval(float u, float v, float /*w*/, unsigned char *pixe
|
|||
if (r < 0)
|
||||
r = 0;
|
||||
|
||||
int pixVal = (int) (r * 255.99f);
|
||||
auto pixVal = (int) (r * 255.99f);
|
||||
#ifdef HDR_COMPRESS
|
||||
pixel[0] = 127;
|
||||
pixel[1] = 127;
|
||||
|
@ -105,14 +105,6 @@ static void GalaxyTextureEval(float u, float v, float /*w*/, unsigned char *pixe
|
|||
}
|
||||
|
||||
|
||||
Galaxy::Galaxy() :
|
||||
detail(1.0f),
|
||||
customTmpName(NULL),
|
||||
form(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
float Galaxy::getDetail() const
|
||||
{
|
||||
return detail;
|
||||
|
@ -127,7 +119,7 @@ void Galaxy::setDetail(float d)
|
|||
|
||||
void Galaxy::setCustomTmpName(const string& tmpNameStr)
|
||||
{
|
||||
if (customTmpName == NULL)
|
||||
if (customTmpName == nullptr)
|
||||
customTmpName = new string(tmpNameStr);
|
||||
else
|
||||
*customTmpName = tmpNameStr;
|
||||
|
@ -136,7 +128,7 @@ void Galaxy::setCustomTmpName(const string& tmpNameStr)
|
|||
|
||||
string Galaxy::getCustomTmpName() const
|
||||
{
|
||||
if (customTmpName == NULL)
|
||||
if (customTmpName == nullptr)
|
||||
return "";
|
||||
else
|
||||
return *customTmpName;
|
||||
|
@ -152,19 +144,15 @@ const char* Galaxy::getType() const
|
|||
void Galaxy::setType(const string& typeStr)
|
||||
{
|
||||
type = Galaxy::Irr;
|
||||
for (int i = 0; i < (int) (sizeof(GalaxyTypeNames) / sizeof(GalaxyTypeNames[0])); ++i)
|
||||
{
|
||||
if (GalaxyTypeNames[i].name == typeStr)
|
||||
{
|
||||
type = GalaxyTypeNames[i].type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto iter = std::find_if(begin(GalaxyTypeNames), end(GalaxyTypeNames),
|
||||
[typeStr](auto& g) { return g.name == typeStr; });
|
||||
if (iter != end(GalaxyTypeNames))
|
||||
type = iter->type;
|
||||
|
||||
if (!formsInitialized)
|
||||
InitializeForms();
|
||||
|
||||
if (customTmpName != NULL)
|
||||
if (customTmpName != nullptr)
|
||||
{
|
||||
form = buildGalacticForms("models/" + *customTmpName);
|
||||
}
|
||||
|
@ -190,7 +178,7 @@ void Galaxy::setType(const string& typeStr)
|
|||
case E6:
|
||||
case E7:
|
||||
form = ellipticalForms[type - E0];
|
||||
//form = NULL;
|
||||
//form = nullptr;
|
||||
break;
|
||||
case Irr:
|
||||
form = irregularForm;
|
||||
|
@ -269,7 +257,7 @@ void Galaxy::render(const GLContext& context,
|
|||
float brightness,
|
||||
float pixelSize)
|
||||
{
|
||||
if (form == NULL)
|
||||
if (form == nullptr)
|
||||
{
|
||||
//renderGalaxyEllipsoid(context, offset, viewerOrientation, brightness, pixelSize);
|
||||
}
|
||||
|
@ -285,13 +273,13 @@ inline void glVertex4(const Vector4f& v)
|
|||
glVertex3fv(v.data());
|
||||
}
|
||||
|
||||
void Galaxy::renderGalaxyPointSprites(const GLContext&,
|
||||
void Galaxy::renderGalaxyPointSprites(const GLContext& /*unused*/,
|
||||
const Vector3f& offset,
|
||||
const Quaternionf& viewerOrientation,
|
||||
float brightness,
|
||||
float pixelSize)
|
||||
{
|
||||
if (form == NULL)
|
||||
if (form == nullptr)
|
||||
return;
|
||||
|
||||
/* We'll first see if the galaxy's apparent size is big enough to
|
||||
|
@ -308,12 +296,12 @@ void Galaxy::renderGalaxyPointSprites(const GLContext&,
|
|||
if (size < minimumFeatureSize)
|
||||
return;
|
||||
|
||||
if (galaxyTex == NULL)
|
||||
if (galaxyTex == nullptr)
|
||||
{
|
||||
galaxyTex = CreateProceduralTexture(width, height, GL_RGBA,
|
||||
GalaxyTextureEval);
|
||||
}
|
||||
assert(galaxyTex != NULL);
|
||||
assert(galaxyTex != nullptr);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
galaxyTex->bind();
|
||||
|
@ -423,7 +411,7 @@ void Galaxy::renderGalaxyEllipsoid(const GLContext& context,
|
|||
nSlices = max(nSlices, 100u);
|
||||
|
||||
VertexProcessor* vproc = context.getVertexProcessor();
|
||||
if (vproc == NULL)
|
||||
if (vproc == nullptr)
|
||||
return;
|
||||
|
||||
//int e = min(max((int) type - (int) E0, 0), 7);
|
||||
|
@ -527,11 +515,11 @@ GalacticForm* buildGalacticForms(const std::string& filename)
|
|||
float h = 0.75f;
|
||||
Image* img;
|
||||
img = LoadPNGImage(filename);
|
||||
if (img == NULL)
|
||||
if (img == nullptr)
|
||||
{
|
||||
cout<<"\nThe galaxy template *** "<<filename<<" *** could not be loaded!\n\n";
|
||||
delete galacticPoints;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
width = img->getWidth();
|
||||
height = img->getHeight();
|
||||
|
@ -603,9 +591,9 @@ GalacticForm* buildGalacticForms(const std::string& filename)
|
|||
|
||||
random_shuffle( galacticPoints->begin() + kmin, galacticPoints->end());
|
||||
|
||||
GalacticForm* galacticForm = new GalacticForm();
|
||||
galacticForm->blobs = galacticPoints;
|
||||
galacticForm->scale = Vector3f::Ones();
|
||||
auto* galacticForm = new GalacticForm();
|
||||
galacticForm->blobs = galacticPoints;
|
||||
galacticForm->scale = Vector3f::Ones();
|
||||
|
||||
return galacticForm;
|
||||
}
|
||||
|
@ -688,8 +676,8 @@ void InitializeForms()
|
|||
{
|
||||
b.position = Vector4f(p.x, p.y, p.z, 1.0f);
|
||||
b.brightness = 64u;
|
||||
unsigned int rr = (unsigned int) (r * 511);
|
||||
b.colorIndex = rr < 256? rr: 255;
|
||||
auto rr = (unsigned int) (r * 511);
|
||||
b.colorIndex = rr < 256 ? rr : 255;
|
||||
irregularPoints->push_back(b);
|
||||
++ip;
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ struct Blob
|
|||
{
|
||||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||
|
||||
Eigen::Vector4f position;
|
||||
unsigned int colorIndex;
|
||||
float brightness;
|
||||
Eigen::Vector4f position;
|
||||
unsigned int colorIndex;
|
||||
float brightness;
|
||||
};
|
||||
|
||||
class GalacticForm;
|
||||
|
@ -30,7 +30,7 @@ class Galaxy : public DeepSkyObject
|
|||
public:
|
||||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||
|
||||
Galaxy();
|
||||
Galaxy() = default;
|
||||
virtual const char* getType() const;
|
||||
virtual void setType(const std::string&);
|
||||
virtual size_t getDescription(char* buf, size_t bufLength) const;
|
||||
|
@ -97,11 +97,11 @@ class Galaxy : public DeepSkyObject
|
|||
};
|
||||
|
||||
private:
|
||||
float detail;
|
||||
std::string* customTmpName;
|
||||
float detail{ 1.0f };
|
||||
std::string* customTmpName{ nullptr };
|
||||
// float brightness;
|
||||
GalaxyType type;
|
||||
GalacticForm* form;
|
||||
GalacticForm* form{ nullptr };
|
||||
|
||||
static float lightGain;
|
||||
};
|
||||
|
|
|
@ -15,28 +15,15 @@
|
|||
using namespace std;
|
||||
|
||||
|
||||
static VertexProcessor* vpNV = NULL;
|
||||
static VertexProcessor* vpARB = NULL;
|
||||
static FragmentProcessor* fpNV = NULL;
|
||||
|
||||
|
||||
GLContext::GLContext() :
|
||||
renderPath(GLPath_Basic),
|
||||
vertexPath(VPath_Basic),
|
||||
vertexProc(NULL),
|
||||
maxSimultaneousTextures(1)
|
||||
{
|
||||
}
|
||||
|
||||
GLContext::~GLContext()
|
||||
{
|
||||
}
|
||||
static VertexProcessor* vpNV = nullptr;
|
||||
static VertexProcessor* vpARB = nullptr;
|
||||
static FragmentProcessor* fpNV = nullptr;
|
||||
|
||||
|
||||
void GLContext::init(const vector<string>& ignoreExt)
|
||||
{
|
||||
char* extensionsString = (char*) glGetString(GL_EXTENSIONS);
|
||||
if (extensionsString != NULL)
|
||||
auto* extensionsString = (char*) glGetString(GL_EXTENSIONS);
|
||||
if (extensionsString != nullptr)
|
||||
{
|
||||
char* next = extensionsString;
|
||||
|
||||
|
@ -48,18 +35,8 @@ void GLContext::init(const vector<string>& ignoreExt)
|
|||
string ext(extensionsString, next - extensionsString);
|
||||
|
||||
// scan the ignore list
|
||||
bool shouldIgnore = false;
|
||||
for (vector<string>::const_iterator iter = ignoreExt.begin();
|
||||
iter != ignoreExt.end(); iter++)
|
||||
{
|
||||
if (*iter == ext)
|
||||
{
|
||||
shouldIgnore = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!shouldIgnore)
|
||||
auto iter = std::find(ignoreExt.begin(), ignoreExt.end(), ext);
|
||||
if (iter == ignoreExt.end())
|
||||
extensions.insert(extensions.end(), ext);
|
||||
|
||||
if (*next == '\0')
|
||||
|
@ -69,7 +46,7 @@ void GLContext::init(const vector<string>& ignoreExt)
|
|||
}
|
||||
}
|
||||
|
||||
if (GLEW_ARB_multitexture && glActiveTextureARB != NULL)
|
||||
if (GLEW_ARB_multitexture && glActiveTextureARB != nullptr)
|
||||
{
|
||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB,
|
||||
(GLint*) &maxSimultaneousTextures);
|
||||
|
@ -78,14 +55,14 @@ void GLContext::init(const vector<string>& ignoreExt)
|
|||
if (GLEW_ARB_vertex_program && glGenProgramsARB)
|
||||
{
|
||||
DPRINTF(1, "Renderer: ARB vertex programs supported.\n");
|
||||
if (vpARB == NULL)
|
||||
if (vpARB == nullptr)
|
||||
vpARB = vp::initARB();
|
||||
vertexProc = vpARB;
|
||||
}
|
||||
else if (GLEW_NV_vertex_program && glGenProgramsNV)
|
||||
{
|
||||
DPRINTF(1, "Renderer: nVidia vertex programs supported.\n");
|
||||
if (vpNV == NULL)
|
||||
if (vpNV == nullptr)
|
||||
vpNV = vp::initNV();
|
||||
vertexProc = vpNV;
|
||||
}
|
||||
|
@ -93,7 +70,7 @@ void GLContext::init(const vector<string>& ignoreExt)
|
|||
if (GLEW_NV_fragment_program && glGenProgramsNV)
|
||||
{
|
||||
DPRINTF(1, "Renderer: nVidia fragment programs supported.\n");
|
||||
if (fpNV == NULL)
|
||||
if (fpNV == nullptr)
|
||||
fpNV = fp::initNV();
|
||||
fragmentProc = fpNV;
|
||||
}
|
||||
|
@ -155,7 +132,7 @@ bool GLContext::renderPathSupported(GLRenderPath path) const
|
|||
case GLPath_DOT3_ARBVP:
|
||||
return GLEW_ARB_texture_env_dot3 &&
|
||||
GLEW_ARB_vertex_program &&
|
||||
vertexProc != NULL;
|
||||
vertexProc != nullptr;
|
||||
|
||||
case GLPath_NvCombiner_NvVP:
|
||||
// If ARB_vertex_program is supported, don't report support for
|
||||
|
@ -163,19 +140,19 @@ bool GLContext::renderPathSupported(GLRenderPath path) const
|
|||
return GLEW_NV_register_combiners &&
|
||||
GLEW_NV_vertex_program &&
|
||||
!GLEW_ARB_vertex_program &&
|
||||
vertexProc != NULL;
|
||||
vertexProc != nullptr;
|
||||
|
||||
case GLPath_NvCombiner_ARBVP:
|
||||
return GLEW_NV_register_combiners &&
|
||||
GLEW_ARB_vertex_program &&
|
||||
vertexProc != NULL;
|
||||
vertexProc != nullptr;
|
||||
|
||||
case GLPath_ARBFP_ARBVP:
|
||||
return false;
|
||||
/*
|
||||
return GLEW_ARB_vertex_program &&
|
||||
GLEW_ARB_fragment_program &&
|
||||
vertexProc != NULL;
|
||||
vertexProc != nullptr;
|
||||
*/
|
||||
|
||||
case GLPath_GLSL:
|
||||
|
@ -226,7 +203,7 @@ GLContext::VertexPath GLContext::getVertexPath() const
|
|||
|
||||
VertexProcessor* GLContext::getVertexProcessor() const
|
||||
{
|
||||
return vertexPath == VPath_Basic ? NULL : vertexProc;
|
||||
return vertexPath == VPath_Basic ? nullptr : vertexProc;
|
||||
}
|
||||
|
||||
|
||||
|
@ -235,5 +212,5 @@ FragmentProcessor* GLContext::getFragmentProcessor() const
|
|||
if (renderPath == GLPath_NV30 /* || renderPath == GLPath_ARGFP_ARBVP */ )
|
||||
return fragmentProc;
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
class GLContext
|
||||
{
|
||||
public:
|
||||
GLContext();
|
||||
virtual ~GLContext();
|
||||
GLContext() = default;
|
||||
virtual ~GLContext() = default;
|
||||
|
||||
enum GLRenderPath
|
||||
{
|
||||
|
@ -60,12 +60,13 @@ class GLContext
|
|||
FragmentProcessor* getFragmentProcessor() const;
|
||||
|
||||
private:
|
||||
GLRenderPath renderPath;
|
||||
VertexPath vertexPath;
|
||||
VertexProcessor* vertexProc;
|
||||
FragmentProcessor* fragmentProc;
|
||||
|
||||
int maxSimultaneousTextures;
|
||||
GLRenderPath renderPath{ GLPath_Basic };
|
||||
VertexPath vertexPath{ VPath_Basic };
|
||||
VertexProcessor* vertexProc{ nullptr };
|
||||
FragmentProcessor* fragmentProc{ nullptr };
|
||||
|
||||
int maxSimultaneousTextures { 1 };
|
||||
std::vector<std::string> extensions;
|
||||
};
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ static const float LumiShape = 3.0f, Lumi0 = exp(-LumiShape);
|
|||
// Reference values ( = data base averages) of core radius, King concentration
|
||||
// and mu25 isophote radius:
|
||||
|
||||
static const float R_c_ref = 0.83f, C_ref = 2.1f, R_mu25 = 40.32f;
|
||||
//static const float R_c_ref = 0.83f, C_ref = 2.1f, R_mu25 = 40.32f;
|
||||
|
||||
// min/max c-values of globular cluster data
|
||||
|
||||
|
@ -56,11 +56,11 @@ static const float P1 = 65.0f, P2 = 0.75f;
|
|||
static const float RRatio_min = pow(10.0f, 1.7f);
|
||||
static float CBin, RRatio, XI, DiskSizeInPixels, Rr = 1.0f, Gg = 1.0f, Bb = 1.0f;
|
||||
|
||||
static GlobularForm** globularForms = NULL;
|
||||
static Texture* globularTex = NULL;
|
||||
static Texture* centerTex[8] = {NULL};
|
||||
static GlobularForm** globularForms = nullptr;
|
||||
static Texture* globularTex = nullptr;
|
||||
static Texture* centerTex[8] = {nullptr};
|
||||
static void InitializeForms();
|
||||
static GlobularForm* buildGlobularForms(float);
|
||||
static GlobularForm* buildGlobularForms(float /*c*/);
|
||||
static bool formsInitialized = false;
|
||||
|
||||
static bool decreasing (const GBlob& b1, const GBlob& b2)
|
||||
|
@ -78,7 +78,7 @@ static void GlobularTextureEval(float u, float v, float /*w*/, unsigned char *pi
|
|||
if (lumi <= 0.0f)
|
||||
lumi = 0.0f;
|
||||
|
||||
int pixVal = (int) (lumi * 255.99f);
|
||||
auto pixVal = (int) (lumi * 255.99f);
|
||||
#ifdef HDR_COMPRESS
|
||||
pixel[0] = 127;
|
||||
pixel[1] = 127;
|
||||
|
@ -155,13 +155,7 @@ static void CenterCloudTexEval(float u, float v, float /*w*/, unsigned char *pix
|
|||
pixel[3] = (int) (relStarDensity(eta) * profile_2d * 255.99f);
|
||||
}
|
||||
|
||||
Globular::Globular() :
|
||||
detail (1.0f),
|
||||
customTmpName (NULL),
|
||||
form (NULL),
|
||||
r_c (R_c_ref),
|
||||
c (C_ref),
|
||||
tidalRadius(0.0f)
|
||||
Globular::Globular()
|
||||
{
|
||||
recomputeTidalRadius();
|
||||
}
|
||||
|
@ -203,7 +197,7 @@ void Globular::setDetail(float d)
|
|||
|
||||
string Globular::getCustomTmpName() const
|
||||
{
|
||||
if (customTmpName == NULL)
|
||||
if (customTmpName == nullptr)
|
||||
return "";
|
||||
else
|
||||
return *customTmpName;
|
||||
|
@ -211,7 +205,7 @@ string Globular::getCustomTmpName() const
|
|||
|
||||
void Globular::setCustomTmpName(const string& tmpNameStr)
|
||||
{
|
||||
if (customTmpName == NULL)
|
||||
if (customTmpName == nullptr)
|
||||
customTmpName = new string(tmpNameStr);
|
||||
else
|
||||
*customTmpName = tmpNameStr;
|
||||
|
@ -333,13 +327,13 @@ void Globular::render(const GLContext& context,
|
|||
}
|
||||
|
||||
|
||||
void Globular::renderGlobularPointSprites(const GLContext&,
|
||||
void Globular::renderGlobularPointSprites(const GLContext& /*unused*/,
|
||||
const Vec3f& offset,
|
||||
const Quatf& viewerOrientation,
|
||||
float brightness,
|
||||
float pixelSize)
|
||||
{
|
||||
if (form == NULL)
|
||||
if (form == nullptr)
|
||||
return;
|
||||
|
||||
float distanceToDSO = offset.length() - getRadius();
|
||||
|
@ -376,18 +370,18 @@ void Globular::renderGlobularPointSprites(const GLContext&,
|
|||
RRatio = pow(10.0f, CBin);
|
||||
XI = 1.0f / sqrt(1.0f + RRatio * RRatio);
|
||||
|
||||
if(centerTex[ic] == NULL)
|
||||
if(centerTex[ic] == nullptr)
|
||||
{
|
||||
centerTex[ic] = CreateProceduralTexture( cntrTexWidth, cntrTexHeight, GL_RGBA, CenterCloudTexEval);
|
||||
}
|
||||
assert(centerTex[ic] != NULL);
|
||||
assert(centerTex[ic] != nullptr);
|
||||
|
||||
if (globularTex == NULL)
|
||||
if (globularTex == nullptr)
|
||||
{
|
||||
globularTex = CreateProceduralTexture( starTexWidth, starTexHeight, GL_RGBA,
|
||||
GlobularTextureEval);
|
||||
}
|
||||
assert(globularTex != NULL);
|
||||
assert(globularTex != nullptr);
|
||||
|
||||
glEnable (GL_BLEND);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
|
@ -524,7 +518,7 @@ void Globular::recomputeTidalRadius()
|
|||
|
||||
GlobularForm* buildGlobularForms(float c)
|
||||
{
|
||||
GBlob b;
|
||||
GBlob b{};
|
||||
vector<GBlob>* globularPoints = new vector<GBlob>;
|
||||
|
||||
float rRatio = pow(10.0f, c); // = r_t / r_c
|
||||
|
@ -614,11 +608,11 @@ GlobularForm* buildGlobularForms(float c)
|
|||
}
|
||||
|
||||
// Check for efficiency of sprite-star generation => close to 100 %!
|
||||
//cout << "c = "<< c <<" i = " << i - 1 <<" k = " << k - 1 << " Efficiency: " << 100.0f * i / (float)k<<"%" << endl;
|
||||
//cout << "c = "<< c <<" i = " << i - 1 <<" k = " << k - 1 << " Efficiency: " << 100.0f * i / (float)k<<"%" << endl;
|
||||
|
||||
GlobularForm* globularForm = new GlobularForm();
|
||||
globularForm->gblobs = globularPoints;
|
||||
globularForm->scale = Vec3f(1.0f, 1.0f, 1.0f);
|
||||
auto* globularForm = new GlobularForm();
|
||||
globularForm->gblobs = globularPoints;
|
||||
globularForm->scale = Vec3f(1.0f, 1.0f, 1.0f);
|
||||
|
||||
return globularForm;
|
||||
}
|
||||
|
|
|
@ -74,15 +74,20 @@ class Globular : public DeepSkyObject
|
|||
virtual const char* getObjTypeName() const;
|
||||
|
||||
private:
|
||||
// Reference values ( = data base averages) of core radius, King concentration
|
||||
// and mu25 isophote radius:
|
||||
|
||||
static constexpr float R_c_ref = 0.83f, C_ref = 2.1f, R_mu25 = 40.32f;
|
||||
|
||||
void recomputeTidalRadius();
|
||||
|
||||
private:
|
||||
float detail;
|
||||
std::string* customTmpName;
|
||||
GlobularForm* form;
|
||||
float r_c;
|
||||
float c;
|
||||
float tidalRadius;
|
||||
float detail{ 1.0f };
|
||||
std::string* customTmpName{ nullptr };
|
||||
GlobularForm* form{ nullptr };
|
||||
float r_c{ R_c_ref };
|
||||
float c{ C_ref };
|
||||
float tidalRadius{ 0.0f };
|
||||
};
|
||||
|
||||
#endif // _GLOBULAR_H_
|
||||
|
|
|
@ -17,7 +17,7 @@ using namespace std;
|
|||
static const string GetInfoLog(GLhandleARB obj);
|
||||
|
||||
|
||||
ostream* g_shaderLogFile = NULL;
|
||||
ostream* g_shaderLogFile = nullptr;
|
||||
|
||||
|
||||
GLShader::GLShader(GLhandleARB _id) :
|
||||
|
@ -40,12 +40,12 @@ GLShader::compile(const vector<string>& source)
|
|||
return ShaderStatus_EmptyProgram;
|
||||
|
||||
// Convert vector of shader source strings to an array for OpenGL
|
||||
const char** sourceStrings = new const char*[source.size()];
|
||||
const auto** sourceStrings = new const char*[source.size()];
|
||||
for (unsigned int i = 0; i < source.size(); i++)
|
||||
sourceStrings[i] = source[i].c_str();
|
||||
|
||||
// Copy shader source to OpenGL
|
||||
glShaderSourceARB(id, source.size(), sourceStrings, NULL);
|
||||
glShaderSourceARB(id, source.size(), sourceStrings, nullptr);
|
||||
delete[] sourceStrings;
|
||||
|
||||
// Actually compile the shader
|
||||
|
@ -164,7 +164,7 @@ GLProgram::link()
|
|||
&linkSuccess);
|
||||
if (linkSuccess == GL_FALSE)
|
||||
{
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Error linking shader program:\n";
|
||||
*g_shaderLogFile << GetInfoLog(getID());
|
||||
|
@ -184,14 +184,14 @@ GLShaderLoader::CreateVertexShader(const vector<string>& source,
|
|||
{
|
||||
GLhandleARB vsid = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
|
||||
|
||||
GLVertexShader* shader = new GLVertexShader(vsid);
|
||||
auto* shader = new GLVertexShader(vsid);
|
||||
if (!shader)
|
||||
return ShaderStatus_OutOfMemory;
|
||||
|
||||
GLShaderStatus status = shader->compile(source);
|
||||
if (status != ShaderStatus_OK)
|
||||
{
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Error compiling vertex shader:\n";
|
||||
*g_shaderLogFile << GetInfoLog(shader->getID());
|
||||
|
@ -212,14 +212,14 @@ GLShaderLoader::CreateFragmentShader(const vector<string>& source,
|
|||
{
|
||||
GLhandleARB fsid = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
|
||||
|
||||
GLFragmentShader* shader = new GLFragmentShader(fsid);
|
||||
auto* shader = new GLFragmentShader(fsid);
|
||||
if (!shader)
|
||||
return ShaderStatus_OutOfMemory;
|
||||
|
||||
GLShaderStatus status = shader->compile(source);
|
||||
if (status != ShaderStatus_OK)
|
||||
{
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Error compiling fragment shader:\n";
|
||||
*g_shaderLogFile << GetInfoLog(shader->getID());
|
||||
|
@ -262,7 +262,7 @@ GLShaderLoader::CreateProgram(const GLVertexShader& vs,
|
|||
{
|
||||
GLhandleARB progid = glCreateProgramObjectARB();
|
||||
|
||||
GLProgram* prog = new GLProgram(progid);
|
||||
auto* prog = new GLProgram(progid);
|
||||
if (!prog)
|
||||
return ShaderStatus_OutOfMemory;
|
||||
|
||||
|
@ -280,12 +280,12 @@ GLShaderLoader::CreateProgram(const vector<string>& vsSource,
|
|||
const vector<string>& fsSource,
|
||||
GLProgram** progOut)
|
||||
{
|
||||
GLVertexShader* vs = NULL;
|
||||
GLVertexShader* vs = nullptr;
|
||||
GLShaderStatus status = CreateVertexShader(vsSource, &vs);
|
||||
if (status != ShaderStatus_OK)
|
||||
return status;
|
||||
|
||||
GLFragmentShader* fs = NULL;
|
||||
GLFragmentShader* fs = nullptr;
|
||||
status = CreateFragmentShader(fsSource, &fs);
|
||||
if (status != ShaderStatus_OK)
|
||||
{
|
||||
|
@ -293,7 +293,7 @@ GLShaderLoader::CreateProgram(const vector<string>& vsSource,
|
|||
return status;
|
||||
}
|
||||
|
||||
GLProgram* prog = NULL;
|
||||
GLProgram* prog = nullptr;
|
||||
status = CreateProgram(*vs, *fs, &prog);
|
||||
if (status != ShaderStatus_OK)
|
||||
{
|
||||
|
@ -337,8 +337,8 @@ GetInfoLog(GLhandleARB obj)
|
|||
if (logLength <= 0)
|
||||
return string();
|
||||
|
||||
char* log = new char[logLength];
|
||||
if (log == NULL)
|
||||
auto* log = new char[logLength];
|
||||
if (!log)
|
||||
return string();
|
||||
|
||||
glGetInfoLogARB(obj, logLength, &charsWritten, log);
|
||||
|
|
|
@ -89,7 +89,7 @@ class FloatShaderParameter
|
|||
{
|
||||
public:
|
||||
FloatShaderParameter();
|
||||
FloatShaderParameter(GLhandleARB _obj, const char* name);
|
||||
FloatShaderParameter(GLhandleARB obj, const char* name);
|
||||
|
||||
FloatShaderParameter& operator=(float);
|
||||
|
||||
|
@ -102,7 +102,7 @@ class Vec3ShaderParameter
|
|||
{
|
||||
public:
|
||||
Vec3ShaderParameter();
|
||||
Vec3ShaderParameter(GLhandleARB _obj, const char* name);
|
||||
Vec3ShaderParameter(GLhandleARB obj, const char* name);
|
||||
|
||||
Vec3ShaderParameter& operator=(const Eigen::Vector3f&);
|
||||
|
||||
|
@ -115,7 +115,7 @@ class Vec4ShaderParameter
|
|||
{
|
||||
public:
|
||||
Vec4ShaderParameter();
|
||||
Vec4ShaderParameter(GLhandleARB _obj, const char* name);
|
||||
Vec4ShaderParameter(GLhandleARB obj, const char* name);
|
||||
|
||||
Vec4ShaderParameter& operator=(const Eigen::Vector4f&);
|
||||
|
||||
|
@ -143,8 +143,8 @@ class GLShaderLoader
|
|||
static GLShaderStatus CreateProgram(const std::vector<std::string>& vs,
|
||||
const std::vector<std::string>& fs,
|
||||
GLProgram**);
|
||||
static GLShaderStatus CreateProgram(const std::string& vs,
|
||||
const std::string& fs,
|
||||
static GLShaderStatus CreateProgram(const std::string& vsSource,
|
||||
const std::string& fsSource,
|
||||
GLProgram**);
|
||||
};
|
||||
|
||||
|
|
|
@ -147,8 +147,7 @@ Image::Image(int fmt, int w, int h, int mips) :
|
|||
width(w),
|
||||
height(h),
|
||||
mipLevels(mips),
|
||||
format(fmt),
|
||||
pixels(NULL)
|
||||
format(fmt)
|
||||
{
|
||||
components = formatComponents(fmt);
|
||||
assert(components != 0);
|
||||
|
@ -164,8 +163,7 @@ Image::Image(int fmt, int w, int h, int mips) :
|
|||
|
||||
Image::~Image()
|
||||
{
|
||||
if (pixels != NULL)
|
||||
delete[] pixels;
|
||||
delete[] pixels;
|
||||
}
|
||||
|
||||
|
||||
|
@ -222,11 +220,11 @@ unsigned char* Image::getPixelRow(int mip, int row)
|
|||
/*int w = max(width >> mip, 1); Unused*/
|
||||
int h = max(height >> mip, 1);
|
||||
if (mip >= mipLevels || row >= h)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// Row addressing of compressed textures is not allowed
|
||||
if (isCompressed())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return getMipLevel(mip) + row * pitch;
|
||||
}
|
||||
|
@ -241,7 +239,7 @@ unsigned char* Image::getPixelRow(int row)
|
|||
unsigned char* Image::getMipLevel(int mip)
|
||||
{
|
||||
if (mip >= mipLevels)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
int offset = 0;
|
||||
for (int i = 0; i < mip; i++)
|
||||
|
@ -255,8 +253,8 @@ int Image::getMipLevelSize(int mip) const
|
|||
{
|
||||
if (mip >= mipLevels)
|
||||
return 0;
|
||||
else
|
||||
return calcMipLevelSize(format, width, height, mip);
|
||||
|
||||
return calcMipLevelSize(format, width, height, mip);
|
||||
}
|
||||
|
||||
|
||||
|
@ -300,11 +298,11 @@ Image* Image::computeNormalMap(float scale, bool wrap) const
|
|||
// Can't do anything with compressed input; there are probably some other
|
||||
// formats that should be rejected as well . . .
|
||||
if (isCompressed())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
Image* normalMap = new Image(GL_RGBA, width, height);
|
||||
if (normalMap == NULL)
|
||||
return NULL;
|
||||
auto* normalMap = new Image(GL_RGBA, width, height);
|
||||
if (!normalMap)
|
||||
return nullptr;
|
||||
|
||||
unsigned char* nmPixels = normalMap->getPixels();
|
||||
int nmPitch = normalMap->getPitch();
|
||||
|
@ -343,14 +341,14 @@ Image* Image::computeNormalMap(float scale, bool wrap) const
|
|||
}
|
||||
}
|
||||
|
||||
int h00 = (int) pixels[i0 * pitch + j0 * components];
|
||||
int h10 = (int) pixels[i0 * pitch + j1 * components];
|
||||
int h01 = (int) pixels[i1 * pitch + j0 * components];
|
||||
auto h00 = (int) pixels[i0 * pitch + j0 * components];
|
||||
auto h10 = (int) pixels[i0 * pitch + j1 * components];
|
||||
auto h01 = (int) pixels[i1 * pitch + j0 * components];
|
||||
|
||||
float dx = (float) (h10 - h00) * (1.0f / 255.0f) * scale;
|
||||
float dy = (float) (h01 - h00) * (1.0f / 255.0f) * scale;
|
||||
|
||||
float mag = (float) sqrt(dx * dx + dy * dy + 1.0f);
|
||||
auto mag = (float) sqrt(dx * dx + dy * dy + 1.0f);
|
||||
float rmag = 1.0f / mag;
|
||||
|
||||
int n = i * nmPitch + j * 4;
|
||||
|
@ -368,7 +366,7 @@ Image* Image::computeNormalMap(float scale, bool wrap) const
|
|||
Image* LoadImageFromFile(const string& filename)
|
||||
{
|
||||
ContentType type = DetermineFileType(filename);
|
||||
Image* img = NULL;
|
||||
Image* img = nullptr;
|
||||
|
||||
clog << _("Loading image from file ") << filename << '\n';
|
||||
|
||||
|
@ -407,12 +405,12 @@ struct my_error_mgr
|
|||
jmp_buf setjmp_buffer; // for return to caller
|
||||
};
|
||||
|
||||
typedef struct my_error_mgr *my_error_ptr;
|
||||
using my_error_ptr = struct my_error_mgr *;
|
||||
|
||||
METHODDEF(void) my_error_exit(j_common_ptr cinfo)
|
||||
{
|
||||
// cinfo->err really points to a my_error_mgr struct, so coerce pointer
|
||||
my_error_ptr myerr = (my_error_ptr) cinfo->err;
|
||||
auto myerr = (my_error_ptr) cinfo->err;
|
||||
|
||||
// Always display the message.
|
||||
// We could postpone this until after returning, if we chose.
|
||||
|
@ -424,10 +422,10 @@ METHODDEF(void) my_error_exit(j_common_ptr cinfo)
|
|||
#endif // JPEG_SUPPORT
|
||||
|
||||
|
||||
Image* LoadJPEGImage(const string& filename, int)
|
||||
Image* LoadJPEGImage(const string& filename, int /*unused*/)
|
||||
{
|
||||
#ifdef JPEG_SUPPORT
|
||||
Image* img = NULL;
|
||||
Image* img = nullptr;
|
||||
|
||||
// This struct contains the JPEG decompression parameters and pointers to
|
||||
// working space (which is allocated as needed by the JPEG library).
|
||||
|
@ -449,8 +447,8 @@ Image* LoadJPEGImage(const string& filename, int)
|
|||
|
||||
FILE *in;
|
||||
in = fopen(filename.c_str(), "rb");
|
||||
if (in == NULL)
|
||||
return NULL;
|
||||
if (!in)
|
||||
return nullptr;
|
||||
|
||||
// Step 1: allocate and initialize JPEG decompression object
|
||||
// We set up the normal JPEG error routines, then override error_exit.
|
||||
|
@ -463,10 +461,9 @@ Image* LoadJPEGImage(const string& filename, int)
|
|||
// We need to clean up the JPEG object, close the input file, and return.
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
fclose(in);
|
||||
if (img != NULL)
|
||||
delete img;
|
||||
delete img;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Now we can initialize the JPEG decompression object.
|
||||
|
@ -556,17 +553,17 @@ Image* LoadJPEGImage(const string& filename, int)
|
|||
|
||||
#elif defined(TARGET_OS_MAC)
|
||||
|
||||
Image* img = NULL;
|
||||
Image* img = nullptr;
|
||||
CGBuffer* cgJpegImage;
|
||||
size_t img_w, img_h, img_d;
|
||||
|
||||
cgJpegImage = new CGBuffer(filename.c_str());
|
||||
if (cgJpegImage == NULL) {
|
||||
if (cgJpegImage == nullptr) {
|
||||
char tempcwd[2048];
|
||||
getcwd(tempcwd, sizeof(tempcwd));
|
||||
DPRINTF(0, "CGBuffer :: Error opening JPEG image file %s/%s\n", tempcwd, filename.c_str());
|
||||
delete cgJpegImage;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!cgJpegImage->LoadJPEG()) {
|
||||
|
@ -574,7 +571,7 @@ Image* LoadJPEGImage(const string& filename, int)
|
|||
getcwd(tempcwd, sizeof(tempcwd));
|
||||
DPRINTF(0, "CGBuffer :: Error loading JPEG image file %s/%s\n", tempcwd, filename.c_str());
|
||||
delete cgJpegImage;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cgJpegImage->Render();
|
||||
|
@ -591,10 +588,10 @@ Image* LoadJPEGImage(const string& filename, int)
|
|||
int format = (img_d == 1) ? GL_LUMINANCE : GL_RGB;
|
||||
#endif
|
||||
img = new Image(format, img_w, img_h);
|
||||
if (img == NULL || img->getPixels() == NULL) {
|
||||
if (img == nullptr || img->getPixels() == nullptr) {
|
||||
DPRINTF(0, "Could not create image\n");
|
||||
delete cgJpegImage;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
// following code flips image and skips alpha byte if no alpha support
|
||||
unsigned char* bout = (unsigned char*) img->getPixels();
|
||||
|
@ -620,7 +617,7 @@ Image* LoadJPEGImage(const string& filename, int)
|
|||
return img;
|
||||
|
||||
#else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#endif // JPEG_SUPPORT
|
||||
}
|
||||
|
||||
|
@ -628,7 +625,7 @@ Image* LoadJPEGImage(const string& filename, int)
|
|||
#ifdef PNG_SUPPORT
|
||||
void PNGReadData(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
FILE* fp = (FILE*) png_get_io_ptr(png_ptr);
|
||||
auto* fp = (FILE*) png_get_io_ptr(png_ptr);
|
||||
if (fread((void*) data, 1, length, fp) != length)
|
||||
cerr << "Error reading PNG data";
|
||||
}
|
||||
|
@ -638,22 +635,22 @@ void PNGReadData(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
Image* LoadPNGImage(const string& filename)
|
||||
{
|
||||
#ifndef PNG_SUPPORT
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#else
|
||||
char header[8];
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
png_uint_32 width, height;
|
||||
int bit_depth, color_type, interlace_type;
|
||||
FILE* fp = NULL;
|
||||
Image* img = NULL;
|
||||
png_bytep* row_pointers = NULL;
|
||||
FILE* fp = nullptr;
|
||||
Image* img = nullptr;
|
||||
png_bytep* row_pointers = nullptr;
|
||||
|
||||
fp = fopen(filename.c_str(), "rb");
|
||||
if (fp == NULL)
|
||||
if (fp == nullptr)
|
||||
{
|
||||
clog << _("Error opening image file ") << filename << '\n';
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t elements_read;
|
||||
|
@ -662,33 +659,32 @@ Image* LoadPNGImage(const string& filename)
|
|||
{
|
||||
clog << _("Error: ") << filename << _(" is not a PNG file.\n");
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||
NULL, NULL, NULL);
|
||||
if (png_ptr == NULL)
|
||||
nullptr, nullptr, nullptr);
|
||||
if (png_ptr == nullptr)
|
||||
{
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL)
|
||||
if (info_ptr == nullptr)
|
||||
{
|
||||
fclose(fp);
|
||||
png_destroy_read_struct(&png_ptr, (png_infopp) NULL, (png_infopp) NULL);
|
||||
return NULL;
|
||||
png_destroy_read_struct(&png_ptr, (png_infopp) nullptr, (png_infopp) nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
{
|
||||
fclose(fp);
|
||||
if (img != NULL)
|
||||
delete img;
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
|
||||
delete img;
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) nullptr);
|
||||
clog << _("Error reading PNG image file ") << filename << '\n';
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// png_init_io(png_ptr, fp);
|
||||
|
@ -700,7 +696,7 @@ Image* LoadPNGImage(const string& filename)
|
|||
png_get_IHDR(png_ptr, info_ptr,
|
||||
&width, &height, &bit_depth,
|
||||
&color_type, &interlace_type,
|
||||
NULL, NULL);
|
||||
nullptr, nullptr);
|
||||
|
||||
GLenum glformat = GL_RGB;
|
||||
switch (color_type)
|
||||
|
@ -724,11 +720,11 @@ Image* LoadPNGImage(const string& filename)
|
|||
}
|
||||
|
||||
img = new Image(glformat, width, height);
|
||||
if (img == NULL)
|
||||
if (img == nullptr)
|
||||
{
|
||||
fclose(fp);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
|
||||
return NULL;
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// TODO: consider using paletted textures if they're available
|
||||
|
@ -762,8 +758,8 @@ Image* LoadPNGImage(const string& filename)
|
|||
|
||||
delete[] row_pointers;
|
||||
|
||||
png_read_end(png_ptr, NULL);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
png_read_end(png_ptr, nullptr);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
|
@ -828,7 +824,7 @@ static Image* LoadBMPImage(ifstream& in)
|
|||
fileHeader.offset = readInt(in);
|
||||
|
||||
if (fileHeader.b != 'B' || fileHeader.m != 'M')
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
imageHeader.size = readInt(in);
|
||||
imageHeader.width = readInt(in);
|
||||
|
@ -843,16 +839,16 @@ static Image* LoadBMPImage(ifstream& in)
|
|||
imageHeader.colorsImportant = readInt(in);
|
||||
|
||||
if (imageHeader.width <= 0 || imageHeader.height <= 0)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// We currently don't support compressed BMPs
|
||||
if (imageHeader.compression != 0)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
// We don't handle 1-, 2-, or 4-bpp images
|
||||
if (imageHeader.bpp != 8 && imageHeader.bpp != 24 && imageHeader.bpp != 32)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
unsigned char* palette = NULL;
|
||||
unsigned char* palette = nullptr;
|
||||
if (imageHeader.bpp == 8)
|
||||
{
|
||||
printf("Reading %d color palette\n", imageHeader.colorsUsed);
|
||||
|
@ -872,13 +868,12 @@ static Image* LoadBMPImage(ifstream& in)
|
|||
|
||||
// check for truncated file
|
||||
|
||||
Image* img = new Image(GL_RGB, imageHeader.width, imageHeader.height);
|
||||
if (img == NULL)
|
||||
auto* img = new Image(GL_RGB, imageHeader.width, imageHeader.height);
|
||||
if (!img)
|
||||
{
|
||||
delete[] pixels;
|
||||
if (palette != NULL)
|
||||
delete[] palette;
|
||||
return NULL;
|
||||
delete[] palette;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Copy the image and perform any necessary conversions
|
||||
|
@ -890,42 +885,34 @@ static Image* LoadBMPImage(ifstream& in)
|
|||
switch (imageHeader.bpp)
|
||||
{
|
||||
case 8:
|
||||
for (int x = 0; x < imageHeader.width; x++)
|
||||
{
|
||||
for (int x = 0; x < imageHeader.width; x++)
|
||||
{
|
||||
unsigned char* color = palette + (*src << 2);
|
||||
dst[0] = color[2];
|
||||
dst[1] = color[1];
|
||||
dst[2] = color[0];
|
||||
src++;
|
||||
dst += 3;
|
||||
}
|
||||
unsigned char* color = palette + (*src << 2);
|
||||
dst[0] = color[2];
|
||||
dst[1] = color[1];
|
||||
dst[2] = color[0];
|
||||
src++;
|
||||
dst += 3;
|
||||
}
|
||||
break;
|
||||
|
||||
case 24:
|
||||
for (int x = 0; x < imageHeader.width; x++)
|
||||
{
|
||||
for (int x = 0; x < imageHeader.width; x++)
|
||||
{
|
||||
dst[0] = src[2];
|
||||
dst[1] = src[1];
|
||||
dst[2] = src[0];
|
||||
src += 3;
|
||||
dst += 3;
|
||||
}
|
||||
dst[0] = src[2];
|
||||
dst[1] = src[1];
|
||||
dst[2] = src[0];
|
||||
src += 3;
|
||||
dst += 3;
|
||||
}
|
||||
break;
|
||||
|
||||
case 32:
|
||||
for (int x = 0; x < imageHeader.width; x++)
|
||||
{
|
||||
for (int x = 0; x < imageHeader.width; x++)
|
||||
{
|
||||
dst[0] = src[2];
|
||||
dst[1] = src[1];
|
||||
dst[2] = src[0];
|
||||
src += 4;
|
||||
dst += 3;
|
||||
}
|
||||
dst[0] = src[2];
|
||||
dst[1] = src[1];
|
||||
dst[2] = src[0];
|
||||
src += 4;
|
||||
dst += 3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -939,7 +926,7 @@ static Image* LoadBMPImage(ifstream& in)
|
|||
|
||||
Image* LoadBMPImage(const string& filename)
|
||||
{
|
||||
ifstream bmpFile(filename.c_str(), ios::in | ios::binary);
|
||||
ifstream bmpFile(filename, ios::in | ios::binary);
|
||||
|
||||
if (bmpFile.good())
|
||||
{
|
||||
|
@ -947,8 +934,6 @@ Image* LoadBMPImage(const string& filename)
|
|||
bmpFile.close();
|
||||
return img;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class Image
|
|||
int components;
|
||||
int format;
|
||||
int size;
|
||||
unsigned char* pixels;
|
||||
unsigned char* pixels{ nullptr };
|
||||
};
|
||||
|
||||
extern Image* LoadJPEGImage(const std::string& filename,
|
||||
|
|
|
@ -73,14 +73,14 @@ public:
|
|||
|
||||
LightingState() :
|
||||
nLights(0),
|
||||
shadowingRingSystem(NULL),
|
||||
shadowingRingSystem(nullptr),
|
||||
eyeDir_obj(-Eigen::Vector3f::UnitZ()),
|
||||
eyePos_obj(-Eigen::Vector3f::UnitZ())
|
||||
{
|
||||
shadows[0] = NULL;
|
||||
shadows[0] = nullptr;
|
||||
for (unsigned int i = 0; i < MaxLights; ++i)
|
||||
{
|
||||
ringShadows[i].ringSystem = NULL;
|
||||
ringShadows[i].ringSystem = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
DirectionalLight lights[MaxLights];
|
||||
EclipseShadowVector* shadows[MaxLights];
|
||||
RingShadow ringShadows[MaxLights];
|
||||
RingSystem* shadowingRingSystem; // NULL when there are no ring shadows
|
||||
RingSystem* shadowingRingSystem; // nullptr when there are no ring shadows
|
||||
Eigen::Vector3f ringPlaneNormal;
|
||||
Eigen::Vector3f ringCenter;
|
||||
|
||||
|
|
|
@ -64,22 +64,9 @@ FeatureNameEntry FeatureNames[] =
|
|||
};
|
||||
|
||||
|
||||
Location::Location() :
|
||||
parent(NULL),
|
||||
position(Vector3f::Zero()),
|
||||
size(0.0f),
|
||||
importance(-1.0f),
|
||||
featureType(Other),
|
||||
overrideLabelColor(false),
|
||||
labelColor(1.0f, 1.0f, 1.0f),
|
||||
infoURL(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
Location::~Location()
|
||||
{
|
||||
if (infoURL != NULL)
|
||||
delete infoURL;
|
||||
delete infoURL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -195,27 +182,18 @@ void Location::setParentBody(Body* _parent)
|
|||
*/
|
||||
Vector3d Location::getPlanetocentricPosition(double t) const
|
||||
{
|
||||
if (parent == NULL)
|
||||
{
|
||||
if (parent == nullptr)
|
||||
return position.cast<double>();
|
||||
}
|
||||
else
|
||||
{
|
||||
Quaterniond q = parent->getEclipticToBodyFixed(t);
|
||||
return q.conjugate() * position.cast<double>();
|
||||
}
|
||||
|
||||
Quaterniond q = parent->getEclipticToBodyFixed(t);
|
||||
return q.conjugate() * position.cast<double>();
|
||||
}
|
||||
|
||||
|
||||
Vector3d Location::getHeliocentricPosition(double t) const
|
||||
{
|
||||
if (parent == NULL)
|
||||
{
|
||||
if (parent == nullptr)
|
||||
return position.cast<double>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent->getAstrocentricPosition(t) + getPlanetocentricPosition(t);
|
||||
}
|
||||
|
||||
return parent->getAstrocentricPosition(t) + getPlanetocentricPosition(t);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class Body;
|
|||
class Location
|
||||
{
|
||||
public:
|
||||
Location();
|
||||
Location() = default;
|
||||
virtual ~Location();
|
||||
|
||||
std::string getName(bool i18n = false) const;
|
||||
|
@ -92,16 +92,16 @@ class Location
|
|||
};
|
||||
|
||||
private:
|
||||
Body* parent;
|
||||
Body* parent{ nullptr };
|
||||
std::string name;
|
||||
std::string i18nName;
|
||||
Eigen::Vector3f position;
|
||||
float size;
|
||||
float importance;
|
||||
uint32 featureType;
|
||||
bool overrideLabelColor;
|
||||
Color labelColor;
|
||||
std::string* infoURL;
|
||||
Eigen::Vector3f position{ Eigen::Vector3f::Zero() };
|
||||
float size{ 0.0f };
|
||||
float importance{ -1.0f };
|
||||
uint32 featureType{ Other };
|
||||
bool overrideLabelColor{ false };
|
||||
Color labelColor{ 1.0f, 1.0f, 1.0f };
|
||||
std::string* infoURL{ nullptr };
|
||||
};
|
||||
|
||||
#endif // _CELENGINE_LOCATION_H_
|
||||
|
|
|
@ -29,10 +29,10 @@ static int maxDivisions = 16384;
|
|||
static int thetaDivisions = maxDivisions;
|
||||
static int phiDivisions = maxDivisions / 2;
|
||||
static int minStep = 128;
|
||||
static float* sinPhi = NULL;
|
||||
static float* cosPhi = NULL;
|
||||
static float* sinTheta = NULL;
|
||||
static float* cosTheta = NULL;
|
||||
static float* sinPhi = nullptr;
|
||||
static float* cosPhi = nullptr;
|
||||
static float* sinTheta = nullptr;
|
||||
static float* cosTheta = nullptr;
|
||||
|
||||
// largest vertex:
|
||||
// position - 3 floats,
|
||||
|
@ -73,31 +73,28 @@ static void InitTrigArrays()
|
|||
}
|
||||
|
||||
|
||||
static float getSphereLOD(float discSizeInPixels)
|
||||
static constexpr float getSphereLOD(float discSizeInPixels)
|
||||
{
|
||||
if (discSizeInPixels < 10)
|
||||
return -3.0f;
|
||||
else if (discSizeInPixels < 20)
|
||||
if (discSizeInPixels < 20)
|
||||
return -2.0f;
|
||||
else if (discSizeInPixels < 50)
|
||||
if (discSizeInPixels < 50)
|
||||
return -1.0f;
|
||||
else if (discSizeInPixels < 200)
|
||||
if (discSizeInPixels < 200)
|
||||
return 0.0f;
|
||||
else if (discSizeInPixels < 1200)
|
||||
if (discSizeInPixels < 1200)
|
||||
return 1.0f;
|
||||
else if (discSizeInPixels < 7200)
|
||||
if (discSizeInPixels < 7200)
|
||||
return 2.0f;
|
||||
else if (discSizeInPixels < 53200)
|
||||
if (discSizeInPixels < 53200)
|
||||
return 3.0f;
|
||||
else
|
||||
return 4.0f;
|
||||
|
||||
return 4.0f;
|
||||
}
|
||||
|
||||
|
||||
LODSphereMesh::LODSphereMesh() :
|
||||
vertices(NULL),
|
||||
vertexBuffersInitialized(false),
|
||||
useVertexBuffers(false)
|
||||
LODSphereMesh::LODSphereMesh()
|
||||
{
|
||||
if (!trigArraysInitialized)
|
||||
InitTrigArrays();
|
||||
|
@ -114,10 +111,8 @@ LODSphereMesh::LODSphereMesh() :
|
|||
|
||||
LODSphereMesh::~LODSphereMesh()
|
||||
{
|
||||
if (vertices != NULL)
|
||||
delete[] vertices;
|
||||
if (indices != NULL)
|
||||
delete[] indices;
|
||||
delete[] vertices;
|
||||
delete[] indices;
|
||||
}
|
||||
|
||||
|
||||
|
@ -153,13 +148,13 @@ void LODSphereMesh::render(const GLContext& context,
|
|||
Texture* textures[MAX_SPHERE_MESH_TEXTURES];
|
||||
int nTextures = 0;
|
||||
|
||||
if (tex0 != NULL)
|
||||
if (tex0 != nullptr)
|
||||
textures[nTextures++] = tex0;
|
||||
if (tex1 != NULL)
|
||||
if (tex1 != nullptr)
|
||||
textures[nTextures++] = tex1;
|
||||
if (tex2 != NULL)
|
||||
if (tex2 != nullptr)
|
||||
textures[nTextures++] = tex2;
|
||||
if (tex3 != NULL)
|
||||
if (tex3 != nullptr)
|
||||
textures[nTextures++] = tex3;
|
||||
render(context, attributes, frustum, pixWidth, textures, nTextures);
|
||||
}
|
||||
|
@ -204,7 +199,7 @@ void LODSphereMesh::render(const GLContext& context,
|
|||
phiExtent /= split;
|
||||
}
|
||||
|
||||
if (tex == NULL)
|
||||
if (tex == nullptr)
|
||||
nTextures = 0;
|
||||
|
||||
|
||||
|
@ -263,15 +258,15 @@ void LODSphereMesh::render(const GLContext& context,
|
|||
vertexBuffersInitialized = true;
|
||||
if (GLEW_ARB_vertex_buffer_object)
|
||||
{
|
||||
for (int i = 0; i < NUM_SPHERE_VERTEX_BUFFERS; i++)
|
||||
for (unsigned int & vertexBuffer : vertexBuffers)
|
||||
{
|
||||
GLuint vbname = 0;
|
||||
glGenBuffersARB(1, &vbname);
|
||||
vertexBuffers[i] = (unsigned int) vbname;
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBuffers[i]);
|
||||
vertexBuffer = (unsigned int) vbname;
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBuffer);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
|
||||
maxVertices * MaxVertexSize * sizeof(float),
|
||||
NULL,
|
||||
nullptr,
|
||||
GL_STREAM_DRAW_ARB);
|
||||
}
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
|
@ -438,7 +433,7 @@ void LODSphereMesh::render(const GLContext& context,
|
|||
{
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
|
||||
vertices = NULL;
|
||||
vertices = nullptr;
|
||||
}
|
||||
|
||||
#ifdef SHOW_FRUSTUM
|
||||
|
@ -600,30 +595,27 @@ int LODSphereMesh::renderPatches(int phi0, int theta0,
|
|||
outside = true;
|
||||
|
||||
if (outside)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (level == 1)
|
||||
|
||||
if (level == 1)
|
||||
{
|
||||
renderSection(phi0, theta0, thetaExtent, ri);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
||||
int nRendered = 0;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
int nRendered = 0;
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
nRendered += renderPatches(phi0 + phiExtent / 2 * i,
|
||||
theta0 + thetaExtent / 2 * j,
|
||||
extent / 2,
|
||||
level / 2,
|
||||
ri);
|
||||
}
|
||||
nRendered += renderPatches(phi0 + phiExtent / 2 * i,
|
||||
theta0 + thetaExtent / 2 * j,
|
||||
extent / 2,
|
||||
level / 2,
|
||||
ri);
|
||||
}
|
||||
return nRendered;
|
||||
}
|
||||
return nRendered;
|
||||
}
|
||||
|
||||
|
||||
|
@ -642,10 +634,10 @@ void LODSphereMesh::renderSection(int phi0, int theta0, int extent,
|
|||
}
|
||||
#endif // SHOW_PATCH_VISIBILITY
|
||||
|
||||
GLsizei stride = (GLsizei) (vertexSize * sizeof(float));
|
||||
auto stride = (GLsizei) (vertexSize * sizeof(float));
|
||||
int tangentOffset = 3;
|
||||
int texCoordOffset = ((ri.attributes & Tangents) != 0) ? 6 : 3;
|
||||
float* vertexBase = useVertexBuffers ? (float*) NULL : vertices;
|
||||
float* vertexBase = useVertexBuffers ? (float*) nullptr : vertices;
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, stride, vertexBase + 0);
|
||||
if ((ri.attributes & Normals) != 0)
|
||||
|
@ -683,17 +675,17 @@ void LODSphereMesh::renderSection(int phi0, int theta0, int extent,
|
|||
|
||||
if (useVertexBuffers)
|
||||
{
|
||||
// Calling glBufferDataARB() with NULL before mapping the buffer
|
||||
// Calling glBufferDataARB() with nullptr before mapping the buffer
|
||||
// is a hint to OpenGL that previous contents of vertex buffer will
|
||||
// be discarded and overwritten. It enables renaming in the driver,
|
||||
// hopefully resulting in performance gains.
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
|
||||
maxVertices * vertexSize * sizeof(float),
|
||||
NULL,
|
||||
nullptr,
|
||||
GL_STREAM_DRAW_ARB);
|
||||
|
||||
vertices = reinterpret_cast<float*>(glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB));
|
||||
if (vertices == NULL)
|
||||
if (vertices == nullptr)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -706,7 +698,7 @@ void LODSphereMesh::renderSection(int phi0, int theta0, int extent,
|
|||
u0[tex] = 1.0f;
|
||||
v0[tex] = 1.0f;
|
||||
|
||||
if (textures[tex] != NULL)
|
||||
if (textures[tex] != nullptr)
|
||||
{
|
||||
int uTexSplit = textures[tex]->getUTileCount(ri.texLOD[tex]);
|
||||
int vTexSplit = textures[tex]->getVTileCount(ri.texLOD[tex]);
|
||||
|
@ -807,7 +799,7 @@ void LODSphereMesh::renderSection(int phi0, int theta0, int extent,
|
|||
|
||||
if (useVertexBuffers)
|
||||
{
|
||||
vertices = NULL;
|
||||
vertices = nullptr;
|
||||
if (!glUnmapBufferARB(GL_ARRAY_BUFFER_ARB))
|
||||
return;
|
||||
}
|
||||
|
@ -816,7 +808,7 @@ void LODSphereMesh::renderSection(int phi0, int theta0, int extent,
|
|||
// int nRings = max(phiExtent / ri.step, 1); // buggy
|
||||
int nRings = phiExtent / ri.step;
|
||||
int nSlices = thetaExtent / ri.step;
|
||||
unsigned short* indexBase = useVertexBuffers ? (unsigned short*) NULL : indices;
|
||||
unsigned short* indexBase = useVertexBuffers ? (unsigned short*) nullptr : indices;
|
||||
for (int i = 0; i < nRings; i++)
|
||||
{
|
||||
glDrawElements(GL_QUAD_STRIP,
|
||||
|
|
|
@ -31,8 +31,8 @@ public:
|
|||
Texture** tex, int nTextures);
|
||||
void render(const GLContext&,
|
||||
unsigned int attributes, const Frustum&, float pixWidth,
|
||||
Texture* tex0 = NULL, Texture* tex1 = NULL,
|
||||
Texture* tex2 = NULL, Texture* tex3 = NULL);
|
||||
Texture* tex0 = nullptr, Texture* tex1 = nullptr,
|
||||
Texture* tex2 = nullptr, Texture* tex3 = nullptr);
|
||||
void render(const GLContext&,
|
||||
const Frustum&, float pixWidth,
|
||||
Texture** tex, int nTextures);
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
void renderSection(int phi0, int theta0, int extent, const RenderInfo&);
|
||||
|
||||
float* vertices;
|
||||
float* vertices{ nullptr };
|
||||
|
||||
int maxVertices;
|
||||
int vertexSize;
|
||||
|
@ -83,12 +83,12 @@ public:
|
|||
int nIndices;
|
||||
unsigned short* indices;
|
||||
|
||||
int nTexturesUsed;
|
||||
int nTexturesUsed{};
|
||||
Texture* textures[MAX_SPHERE_MESH_TEXTURES];
|
||||
unsigned int subtextures[MAX_SPHERE_MESH_TEXTURES];
|
||||
unsigned int subtextures[MAX_SPHERE_MESH_TEXTURES]{};
|
||||
|
||||
bool vertexBuffersInitialized;
|
||||
bool useVertexBuffers;
|
||||
bool vertexBuffersInitialized{ false };
|
||||
bool useVertexBuffers{ false };
|
||||
int currentVB;
|
||||
unsigned int vertexBuffers[NUM_SPHERE_VERTEX_BUFFERS];
|
||||
GLuint indexBuffer;
|
||||
|
|
|
@ -14,20 +14,6 @@
|
|||
using namespace std;
|
||||
|
||||
|
||||
Marker::Marker(const Selection& s) :
|
||||
m_object(s),
|
||||
m_priority(0),
|
||||
m_representation(MarkerRepresentation::Diamond),
|
||||
m_occludable(true),
|
||||
m_sizing(ConstantSize)
|
||||
{
|
||||
}
|
||||
|
||||
Marker::~Marker()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
UniversalCoord Marker::position(double jd) const
|
||||
{
|
||||
return m_object.getPosition(jd);
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
enum Symbol
|
||||
{
|
||||
Diamond = 0,
|
||||
Triangle = 1,
|
||||
Triangle = 1,
|
||||
Square = 2,
|
||||
FilledSquare = 3,
|
||||
Plus = 4,
|
||||
|
@ -32,9 +32,9 @@ public:
|
|||
RightArrow = 7,
|
||||
UpArrow = 8,
|
||||
DownArrow = 9,
|
||||
Circle = 10,
|
||||
Disk = 11,
|
||||
Crosshair = 12,
|
||||
Circle = 10,
|
||||
Disk = 11,
|
||||
Crosshair = 12,
|
||||
};
|
||||
|
||||
MarkerRepresentation(Symbol symbol = MarkerRepresentation::Diamond,
|
||||
|
@ -87,8 +87,8 @@ enum MarkerSizing
|
|||
class Marker
|
||||
{
|
||||
public:
|
||||
Marker(const Selection&);
|
||||
~Marker();
|
||||
Marker(const Selection& s) : m_object(s) {};
|
||||
~Marker() = default;
|
||||
|
||||
UniversalCoord position(double jd) const;
|
||||
Selection object() const;
|
||||
|
@ -108,10 +108,10 @@ class Marker
|
|||
|
||||
private:
|
||||
Selection m_object;
|
||||
int m_priority;
|
||||
MarkerRepresentation m_representation;
|
||||
bool m_occludable : 1;
|
||||
MarkerSizing m_sizing : 2;
|
||||
int m_priority{ 0 };
|
||||
MarkerRepresentation m_representation{ MarkerRepresentation::Diamond };
|
||||
bool m_occludable { true };
|
||||
MarkerSizing m_sizing { ConstantSize };
|
||||
};
|
||||
|
||||
typedef std::vector<Marker> MarkerList;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include <utility>
|
||||
|
||||
|
||||
|
||||
|
@ -45,7 +46,7 @@ using namespace std;
|
|||
static Model* LoadCelestiaMesh(const string& filename);
|
||||
static Model* Convert3DSModel(const M3DScene& scene, const string& texPath);
|
||||
|
||||
static GeometryManager* geometryManager = NULL;
|
||||
static GeometryManager* geometryManager = nullptr;
|
||||
|
||||
static const char UniqueSuffixChar = '!';
|
||||
|
||||
|
@ -53,12 +54,12 @@ static const char UniqueSuffixChar = '!';
|
|||
class CelestiaTextureLoader : public cmod::TextureLoader
|
||||
{
|
||||
public:
|
||||
CelestiaTextureLoader(const std::string& texturePath) :
|
||||
m_texturePath(texturePath)
|
||||
CelestiaTextureLoader(std::string texturePath) :
|
||||
m_texturePath(std::move(texturePath))
|
||||
{
|
||||
}
|
||||
|
||||
~CelestiaTextureLoader() {}
|
||||
~CelestiaTextureLoader() = default;
|
||||
|
||||
Material::TextureResource* loadTexture(const std::string& name)
|
||||
{
|
||||
|
@ -73,7 +74,7 @@ private:
|
|||
|
||||
GeometryManager* GetGeometryManager()
|
||||
{
|
||||
if (geometryManager == NULL)
|
||||
if (geometryManager == nullptr)
|
||||
geometryManager = new GeometryManager("models");
|
||||
return geometryManager;
|
||||
}
|
||||
|
@ -90,7 +91,7 @@ string GeometryInfo::resolve(const string& baseDir)
|
|||
if (!path.empty())
|
||||
{
|
||||
string filename = path + "/models/" + source;
|
||||
ifstream in(filename.c_str());
|
||||
ifstream in(filename);
|
||||
if (in.good())
|
||||
{
|
||||
resolvedToPath = true;
|
||||
|
@ -109,13 +110,13 @@ Geometry* GeometryInfo::load(const string& resolvedFilename)
|
|||
string filename(resolvedFilename, 0, uniquifyingSuffixStart);
|
||||
|
||||
clog << _("Loading model: ") << filename << '\n';
|
||||
Model* model = NULL;
|
||||
Model* model = nullptr;
|
||||
ContentType fileType = DetermineFileType(filename);
|
||||
|
||||
if (fileType == Content_3DStudio)
|
||||
{
|
||||
M3DScene* scene = Read3DSFile(filename);
|
||||
if (scene != NULL)
|
||||
if (scene != nullptr)
|
||||
{
|
||||
if (resolvedToPath)
|
||||
model = Convert3DSModel(*scene, path);
|
||||
|
@ -132,13 +133,13 @@ Geometry* GeometryInfo::load(const string& resolvedFilename)
|
|||
}
|
||||
else if (fileType == Content_CelestiaModel)
|
||||
{
|
||||
ifstream in(filename.c_str(), ios::binary);
|
||||
ifstream in(filename, ios::binary);
|
||||
if (in.good())
|
||||
{
|
||||
CelestiaTextureLoader textureLoader(path);
|
||||
|
||||
model = LoadModel(in, &textureLoader);
|
||||
if (model != NULL)
|
||||
if (model != nullptr)
|
||||
{
|
||||
if (isNormalized)
|
||||
model->normalize(center);
|
||||
|
@ -150,7 +151,7 @@ Geometry* GeometryInfo::load(const string& resolvedFilename)
|
|||
else if (fileType == Content_CelestiaMesh)
|
||||
{
|
||||
model = LoadCelestiaMesh(filename);
|
||||
if (model != NULL)
|
||||
if (model != nullptr)
|
||||
{
|
||||
if (isNormalized)
|
||||
model->normalize(center);
|
||||
|
@ -161,7 +162,7 @@ Geometry* GeometryInfo::load(const string& resolvedFilename)
|
|||
#if PARTICLE_SYSTEM
|
||||
else if (fileType == Content_CelestiaParticleSystem)
|
||||
{
|
||||
ifstream in(filename.c_str());
|
||||
ifstream in(filename);
|
||||
if (in.good())
|
||||
{
|
||||
return LoadParticleSystem(in, path);
|
||||
|
@ -170,7 +171,7 @@ Geometry* GeometryInfo::load(const string& resolvedFilename)
|
|||
#endif
|
||||
|
||||
// Condition the model for optimal rendering
|
||||
if (model != NULL)
|
||||
if (model != nullptr)
|
||||
{
|
||||
// Many models tend to have a lot of duplicate materials; eliminate
|
||||
// them, since unnecessarily setting material parameters can adversely
|
||||
|
@ -199,7 +200,7 @@ Geometry* GeometryInfo::load(const string& resolvedFilename)
|
|||
else
|
||||
{
|
||||
clog << _("Error loading model '") << filename << "'\n";
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,8 +224,8 @@ static float NoiseDisplacementFunc(float u, float v, void* info)
|
|||
float y = (float) sin(phi);
|
||||
float z = (float) (cos(phi) * sin(theta));
|
||||
|
||||
// assert(info != NULL);
|
||||
NoiseMeshParameters* params = (NoiseMeshParameters*) info;
|
||||
// assert(info != nullptr);
|
||||
auto* params = (NoiseMeshParameters*) info;
|
||||
|
||||
Vector3f p = Vector3f(x, y, z) + params->offset;
|
||||
return fractalsum(p, params->octaves) * params->featureHeight;
|
||||
|
@ -234,11 +235,11 @@ static float NoiseDisplacementFunc(float u, float v, void* info)
|
|||
// TODO: The Celestia mesh format is deprecated
|
||||
Model* LoadCelestiaMesh(const string& filename)
|
||||
{
|
||||
ifstream meshFile(filename.c_str(), ios::in);
|
||||
ifstream meshFile(filename, ios::in);
|
||||
if (!meshFile.good())
|
||||
{
|
||||
DPRINTF(0, "Error opening mesh file: %s\n", filename.c_str());
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Tokenizer tokenizer(&meshFile);
|
||||
|
@ -247,7 +248,7 @@ Model* LoadCelestiaMesh(const string& filename)
|
|||
if (tokenizer.nextToken() != Tokenizer::TokenName)
|
||||
{
|
||||
DPRINTF(0, "Mesh file %s is invalid.\n", filename.c_str());
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (tokenizer.getStringValue() != "SphereDisplacementMesh")
|
||||
|
@ -255,26 +256,26 @@ Model* LoadCelestiaMesh(const string& filename)
|
|||
DPRINTF(0, "%s: Unrecognized mesh type %s.\n",
|
||||
filename.c_str(),
|
||||
tokenizer.getStringValue().c_str());
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Value* meshDefValue = parser.readValue();
|
||||
if (meshDefValue == NULL)
|
||||
if (meshDefValue == nullptr)
|
||||
{
|
||||
DPRINTF(0, "%s: Bad mesh file.\n", filename.c_str());
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (meshDefValue->getType() != Value::HashType)
|
||||
{
|
||||
DPRINTF(0, "%s: Bad mesh file.\n", filename.c_str());
|
||||
delete meshDefValue;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Hash* meshDef = meshDefValue->getHash();
|
||||
|
||||
NoiseMeshParameters params;
|
||||
NoiseMeshParameters params{};
|
||||
|
||||
params.size = Vector3f::Ones();
|
||||
params.offset = Vector3f::Constant(10.0f);
|
||||
|
@ -297,7 +298,7 @@ Model* LoadCelestiaMesh(const string& filename)
|
|||
(int) params.rings, (int) params.slices,
|
||||
NoiseDisplacementFunc,
|
||||
(void*) ¶ms);
|
||||
if (sphereMesh != NULL)
|
||||
if (sphereMesh != nullptr)
|
||||
{
|
||||
Mesh* mesh = sphereMesh->convertToMesh();
|
||||
model->addMesh(mesh);
|
||||
|
@ -349,13 +350,13 @@ ConvertTriangleMesh(M3DTriangleMesh& mesh,
|
|||
|
||||
Vector3f* faceNormals = new Vector3f[nFaces];
|
||||
Vector3f* vertexNormals = new Vector3f[nFaces * 3];
|
||||
int* faceCounts = new int[nVertices];
|
||||
int** vertexFaces = new int*[nVertices];
|
||||
auto* faceCounts = new int[nVertices];
|
||||
auto** vertexFaces = new int*[nVertices];
|
||||
|
||||
for (int i = 0; i < nVertices; i++)
|
||||
{
|
||||
faceCounts[i] = 0;
|
||||
vertexFaces[i] = NULL;
|
||||
vertexFaces[i] = nullptr;
|
||||
}
|
||||
|
||||
// generate face normals
|
||||
|
@ -444,7 +445,7 @@ ConvertTriangleMesh(M3DTriangleMesh& mesh,
|
|||
|
||||
// Create the vertex data
|
||||
unsigned int floatsPerVertex = vertexSize / sizeof(float);
|
||||
float* vertexData = new float[nFaces * 3 * floatsPerVertex];
|
||||
auto* vertexData = new float[nFaces * 3 * floatsPerVertex];
|
||||
|
||||
for (int i = 0; i < nFaces; i++)
|
||||
{
|
||||
|
@ -509,17 +510,15 @@ ConvertTriangleMesh(M3DTriangleMesh& mesh,
|
|||
}
|
||||
|
||||
// clean up
|
||||
if (faceNormals != NULL)
|
||||
delete[] faceNormals;
|
||||
if (vertexNormals != NULL)
|
||||
delete[] vertexNormals;
|
||||
if (faceCounts != NULL)
|
||||
delete[] faceCounts;
|
||||
if (vertexFaces != NULL)
|
||||
delete[] faceNormals;
|
||||
delete[] vertexNormals;
|
||||
delete[] faceCounts;
|
||||
|
||||
if (vertexFaces != nullptr)
|
||||
{
|
||||
for (int i = 0; i < nVertices; i++)
|
||||
{
|
||||
if (vertexFaces[i] != NULL)
|
||||
if (vertexFaces[i] != nullptr)
|
||||
delete[] vertexFaces[i];
|
||||
}
|
||||
delete[] vertexFaces;
|
||||
|
@ -532,7 +531,7 @@ ConvertTriangleMesh(M3DTriangleMesh& mesh,
|
|||
static Material::Color
|
||||
toMaterialColor(Color c)
|
||||
{
|
||||
return Material::Color(c.red(), c.green(), c.blue());
|
||||
return {c.red(), c.green(), c.blue()};
|
||||
}
|
||||
|
||||
|
||||
|
@ -578,12 +577,12 @@ Convert3DSModel(const M3DScene& scene, const string& texPath)
|
|||
for (uint32 i = 0; i < scene.getModelCount(); i++)
|
||||
{
|
||||
M3DModel* model3ds = scene.getModel(i);
|
||||
if (model3ds != NULL)
|
||||
if (model3ds)
|
||||
{
|
||||
for (unsigned int j = 0; j < model3ds->getTriMeshCount(); j++)
|
||||
{
|
||||
M3DTriangleMesh* mesh = model3ds->getTriMesh(j);
|
||||
if (mesh != NULL)
|
||||
if (mesh)
|
||||
{
|
||||
Mesh* newMesh = ConvertTriangleMesh(*mesh, scene);
|
||||
model->addMesh(newMesh);
|
||||
|
|
|
@ -44,15 +44,12 @@ static bool isVBOSupported()
|
|||
class ModelOpenGLData
|
||||
{
|
||||
public:
|
||||
ModelOpenGLData()
|
||||
{
|
||||
}
|
||||
ModelOpenGLData() = default;
|
||||
|
||||
~ModelOpenGLData()
|
||||
{
|
||||
for (vector<GLuint>::iterator iter = vbos.begin(); iter != vbos.end(); ++iter)
|
||||
for (auto vboId : vbos)
|
||||
{
|
||||
GLuint vboId = *iter;
|
||||
if (vboId != 0)
|
||||
{
|
||||
glDeleteBuffersARB(1, &vboId);
|
||||
|
@ -68,9 +65,7 @@ public:
|
|||
* The ModelGeoemtry takes ownership of the model.
|
||||
*/
|
||||
ModelGeometry::ModelGeometry(Model* model) :
|
||||
m_model(model),
|
||||
m_vbInitialized(false),
|
||||
m_glData(NULL)
|
||||
m_model(model)
|
||||
{
|
||||
m_glData = new ModelOpenGLData();
|
||||
}
|
||||
|
@ -149,7 +144,7 @@ ModelGeometry::render(RenderContext& rc, double /* t */)
|
|||
{
|
||||
// Bind the vertex buffer object.
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboId);
|
||||
rc.setVertexArrays(mesh->getVertexDescription(), NULL);
|
||||
rc.setVertexArrays(mesh->getVertexDescription(), nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -163,7 +158,7 @@ ModelGeometry::render(RenderContext& rc, double /* t */)
|
|||
const Mesh::PrimitiveGroup* group = mesh->getGroup(groupIndex);
|
||||
|
||||
// Set up the material
|
||||
const Material* material = NULL;
|
||||
const Material* material = nullptr;
|
||||
unsigned int materialIndex = group->materialIndex;
|
||||
if (materialIndex != lastMaterial && materialIndex < materialCount)
|
||||
{
|
||||
|
@ -208,11 +203,8 @@ void
|
|||
ModelGeometry::loadTextures()
|
||||
{
|
||||
#if 0
|
||||
for (vector<const Material*>::const_iterator iter = materials.begin();
|
||||
iter != materials.end(); iter++)
|
||||
for (const auto m : materials)
|
||||
{
|
||||
const Mesh::Material* m = *iter;
|
||||
|
||||
if (m->maps[Mesh::DiffuseMap] != InvalidResource)
|
||||
GetTextureManager()->find(m->maps[Mesh::DiffuseMap]);
|
||||
if (m->maps[Mesh::NormalMap] != InvalidResource)
|
||||
|
@ -230,19 +222,8 @@ string
|
|||
CelestiaTextureResource::source() const
|
||||
{
|
||||
if (m_textureHandle == InvalidResource)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
const TextureInfo* t = GetTextureManager()->getResourceInfo(textureHandle());
|
||||
if (!t)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return t->source;
|
||||
}
|
||||
}
|
||||
|
||||
const TextureInfo* t = GetTextureManager()->getResourceInfo(textureHandle());
|
||||
return t ? t->source : "";
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ class ModelGeometry : public Geometry
|
|||
|
||||
private:
|
||||
cmod::Model* m_model;
|
||||
bool m_vbInitialized;
|
||||
ModelOpenGLData* m_glData;
|
||||
bool m_vbInitialized{ false };
|
||||
ModelOpenGLData* m_glData{ nullptr };
|
||||
};
|
||||
|
||||
#endif // !_CELENGINE_MODEL_H_
|
||||
|
|
|
@ -64,7 +64,7 @@ Texture* MultiResTexture::find(unsigned int resolution)
|
|||
TextureManager* texMan = GetTextureManager();
|
||||
|
||||
Texture* res = texMan->find(tex[resolution]);
|
||||
if (res != NULL)
|
||||
if (res != nullptr)
|
||||
return res;
|
||||
|
||||
// Preferred resolution isn't available; try the second choice
|
||||
|
@ -90,7 +90,7 @@ Texture* MultiResTexture::find(unsigned int resolution)
|
|||
|
||||
tex[resolution] = tex[secondChoice];
|
||||
res = texMan->find(tex[resolution]);
|
||||
if (res != NULL)
|
||||
if (res != nullptr)
|
||||
return res;
|
||||
|
||||
tex[resolution] = tex[lastResort];
|
||||
|
|
|
@ -24,12 +24,6 @@ using namespace Eigen;
|
|||
using namespace std;
|
||||
|
||||
|
||||
Nebula::Nebula() :
|
||||
geometry(InvalidResource)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const char* Nebula::getType() const
|
||||
{
|
||||
return "Nebula";
|
||||
|
@ -88,15 +82,15 @@ bool Nebula::load(AssociativeArray* params, const string& resPath)
|
|||
|
||||
|
||||
void Nebula::render(const GLContext& glcontext,
|
||||
const Vector3f&,
|
||||
const Quaternionf&,
|
||||
float,
|
||||
const Vector3f& /*unused*/,
|
||||
const Quaternionf& /*unused*/,
|
||||
float /*unused*/,
|
||||
float pixelSize)
|
||||
{
|
||||
Geometry* g = NULL;
|
||||
Geometry* g = nullptr;
|
||||
if (geometry != InvalidResource)
|
||||
g = GetGeometryManager()->find(geometry);
|
||||
if (g == NULL)
|
||||
if (g == nullptr)
|
||||
return;
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
|
|
@ -19,7 +19,7 @@ class Nebula : public DeepSkyObject
|
|||
public:
|
||||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||
|
||||
Nebula();
|
||||
Nebula() = default;
|
||||
|
||||
virtual const char* getType() const;
|
||||
virtual void setType(const std::string&);
|
||||
|
@ -57,7 +57,7 @@ class Nebula : public DeepSkyObject
|
|||
};
|
||||
|
||||
private:
|
||||
ResourceHandle geometry;
|
||||
ResourceHandle geometry{ InvalidResource };
|
||||
};
|
||||
|
||||
#endif // CELENGINE_NEBULA_H_
|
||||
|
|
|
@ -55,23 +55,7 @@ static Vector3d slerp(double t, const Vector3d& v0, const Vector3d& v1)
|
|||
* updates due to an active goto operation.
|
||||
*/
|
||||
|
||||
Observer::Observer() :
|
||||
simTime(0.0),
|
||||
position(0.0, 0.0, 0.0),
|
||||
orientation(Quaternionf::Identity()),
|
||||
velocity(0.0, 0.0, 0.0),
|
||||
angularVelocity(0.0, 0.0, 0.0),
|
||||
frame(NULL),
|
||||
realTime(0.0),
|
||||
targetSpeed(0.0),
|
||||
targetVelocity(0.0, 0.0, 0.0),
|
||||
initialVelocity(0.0, 0.0, 0.0),
|
||||
beginAccelTime(0.0),
|
||||
observerMode(Free),
|
||||
trackingOrientation(Quaternionf::Identity()),
|
||||
fov((float) (PI / 4.0)),
|
||||
reverseFlag(false),
|
||||
locationFilter(~0u)
|
||||
Observer::Observer()
|
||||
{
|
||||
frame = new ObserverFrame();
|
||||
updateUniversal();
|
||||
|
@ -85,7 +69,7 @@ Observer::Observer(const Observer& o) :
|
|||
orientation(o.orientation),
|
||||
velocity(o.velocity),
|
||||
angularVelocity(o.angularVelocity),
|
||||
frame(NULL),
|
||||
frame(nullptr),
|
||||
realTime(o.realTime),
|
||||
targetSpeed(o.targetSpeed),
|
||||
targetVelocity(o.targetVelocity),
|
||||
|
@ -115,7 +99,7 @@ Observer& Observer::operator=(const Observer& o)
|
|||
orientation = o.orientation;
|
||||
velocity = o.velocity;
|
||||
angularVelocity = o.angularVelocity;
|
||||
frame = NULL;
|
||||
frame = nullptr;
|
||||
realTime = o.realTime;
|
||||
targetSpeed = o.targetSpeed;
|
||||
targetVelocity = o.targetVelocity;
|
||||
|
@ -298,8 +282,8 @@ double Observer::getArrivalTime() const
|
|||
{
|
||||
if (observerMode != Travelling)
|
||||
return realTime;
|
||||
else
|
||||
return journey.startTime + journey.duration;
|
||||
|
||||
return journey.startTime + journey.duration;
|
||||
}
|
||||
|
||||
|
||||
|
@ -375,12 +359,12 @@ void Observer::update(double dt, double timeScale)
|
|||
else if (journey.traj == GreatCircle)
|
||||
{
|
||||
Selection centerObj = frame->getRefObject();
|
||||
if (centerObj.body() != NULL)
|
||||
if (centerObj.body() != nullptr)
|
||||
{
|
||||
Body* body = centerObj.body();
|
||||
if (body->getSystem())
|
||||
{
|
||||
if (body->getSystem()->getPrimaryBody() != NULL)
|
||||
if (body->getSystem()->getPrimaryBody() != nullptr)
|
||||
centerObj = Selection(body->getSystem()->getPrimaryBody());
|
||||
else
|
||||
centerObj = Selection(body->getSystem()->getStar());
|
||||
|
@ -869,7 +853,7 @@ void Observer::convertFrameCoordinates(const ObserverFrame* newFrame)
|
|||
void Observer::setFrame(ObserverFrame::CoordinateSystem cs, const Selection& refObj, const Selection& targetObj)
|
||||
{
|
||||
ObserverFrame* newFrame = new ObserverFrame(cs, refObj, targetObj);
|
||||
if (newFrame != NULL)
|
||||
if (newFrame != nullptr)
|
||||
{
|
||||
convertFrameCoordinates(newFrame);
|
||||
delete frame;
|
||||
|
@ -894,11 +878,11 @@ void Observer::setFrame(const ObserverFrame& f)
|
|||
{
|
||||
if (frame != &f)
|
||||
{
|
||||
ObserverFrame* newFrame = new ObserverFrame(f);
|
||||
auto* newFrame = new ObserverFrame(f);
|
||||
|
||||
if (newFrame != NULL)
|
||||
if (newFrame != nullptr)
|
||||
{
|
||||
if (frame != NULL)
|
||||
if (frame != nullptr)
|
||||
{
|
||||
convertFrameCoordinates(newFrame);
|
||||
delete frame;
|
||||
|
@ -1089,7 +1073,7 @@ static double getPreferredDistance(const Selection& selection)
|
|||
if (selection.body()->getClassification() == Body::Invisible)
|
||||
{
|
||||
double r = selection.body()->getRadius();
|
||||
if (selection.body()->getFrameTree() != NULL)
|
||||
if (selection.body()->getFrameTree() != nullptr)
|
||||
r = selection.body()->getFrameTree()->boundingSphereRadius();
|
||||
return min(astro::lightYearsToKilometers(0.1), r * 5.0);
|
||||
}
|
||||
|
@ -1112,21 +1096,17 @@ static double getPreferredDistance(const Selection& selection)
|
|||
// for reference points in solar systems.
|
||||
double maxOrbitRadius = 0.0;
|
||||
const vector<Star*>* orbitingStars = selection.star()->getOrbitingStars();
|
||||
if (orbitingStars != NULL)
|
||||
if (orbitingStars != nullptr)
|
||||
{
|
||||
for (vector<Star*>::const_iterator iter = orbitingStars->begin();
|
||||
iter != orbitingStars->end(); iter++)
|
||||
for (const auto star : *orbitingStars)
|
||||
{
|
||||
Orbit* orbit = (*iter)->getOrbit();
|
||||
if (orbit != NULL)
|
||||
Orbit* orbit = star->getOrbit();
|
||||
if (orbit != nullptr)
|
||||
maxOrbitRadius = max(orbit->getBoundingRadius(), maxOrbitRadius);
|
||||
}
|
||||
}
|
||||
|
||||
if (maxOrbitRadius == 0.0)
|
||||
return astro::AUtoKilometers(1.0);
|
||||
else
|
||||
return maxOrbitRadius * 5.0;
|
||||
return maxOrbitRadius == 0.0 ? astro::AUtoKilometers(1.0) : maxOrbitRadius * 5.0;
|
||||
}
|
||||
|
||||
case Selection::Type_Location:
|
||||
|
@ -1204,7 +1184,7 @@ void Observer::gotoSelectionGC(const Selection& selection,
|
|||
Vector3d viewVec = pos.offsetFromKm(getPosition());
|
||||
double orbitDistance = getOrbitDistance(selection, viewVec.norm());
|
||||
|
||||
if (selection.location() != NULL)
|
||||
if (selection.location() != nullptr)
|
||||
{
|
||||
Selection parent = selection.parent();
|
||||
double maintainDist = getPreferredDistance(parent);
|
||||
|
@ -1404,9 +1384,9 @@ void Observer::follow(const Selection& selection)
|
|||
|
||||
void Observer::geosynchronousFollow(const Selection& selection)
|
||||
{
|
||||
if (selection.body() != NULL ||
|
||||
selection.location() != NULL ||
|
||||
selection.star() != NULL)
|
||||
if (selection.body() != nullptr ||
|
||||
selection.location() != nullptr ||
|
||||
selection.star() != nullptr)
|
||||
{
|
||||
setFrame(ObserverFrame::BodyFixed, selection);
|
||||
}
|
||||
|
@ -1419,7 +1399,7 @@ void Observer::phaseLock(const Selection& selection)
|
|||
|
||||
if (selection != refObject)
|
||||
{
|
||||
if (refObject.body() != NULL || refObject.star() != NULL)
|
||||
if (refObject.body() != nullptr || refObject.star() != nullptr)
|
||||
{
|
||||
setFrame(ObserverFrame::PhaseLock, refObject, selection);
|
||||
}
|
||||
|
@ -1428,7 +1408,7 @@ void Observer::phaseLock(const Selection& selection)
|
|||
{
|
||||
// Selection and reference object are identical, so the frame is undefined.
|
||||
// We'll instead use the object's star as the target object.
|
||||
if (selection.body() != NULL)
|
||||
if (selection.body() != nullptr)
|
||||
{
|
||||
setFrame(ObserverFrame::PhaseLock, selection, Selection(selection.body()->getSystem()->getStar()));
|
||||
}
|
||||
|
@ -1438,7 +1418,7 @@ void Observer::phaseLock(const Selection& selection)
|
|||
|
||||
void Observer::chase(const Selection& selection)
|
||||
{
|
||||
if (selection.body() != NULL || selection.star() != NULL)
|
||||
if (selection.body() != nullptr || selection.star() != nullptr)
|
||||
{
|
||||
setFrame(ObserverFrame::Chase, selection);
|
||||
}
|
||||
|
@ -1481,7 +1461,7 @@ void Observer::updateUniversal()
|
|||
*/
|
||||
ObserverFrame::ObserverFrame() :
|
||||
coordSys(Universal),
|
||||
frame(NULL)
|
||||
frame(nullptr)
|
||||
{
|
||||
frame = createFrame(Universal, Selection(), Selection());
|
||||
frame->addRef();
|
||||
|
@ -1496,7 +1476,7 @@ ObserverFrame::ObserverFrame(CoordinateSystem _coordSys,
|
|||
const Selection& _refObject,
|
||||
const Selection& _targetObject) :
|
||||
coordSys(_coordSys),
|
||||
frame(NULL),
|
||||
frame(nullptr),
|
||||
targetObject(_targetObject)
|
||||
{
|
||||
frame = createFrame(_coordSys, _refObject, _targetObject);
|
||||
|
@ -1541,7 +1521,7 @@ ObserverFrame& ObserverFrame::operator=(const ObserverFrame& f)
|
|||
|
||||
ObserverFrame::~ObserverFrame()
|
||||
{
|
||||
if (frame != NULL)
|
||||
if (frame != nullptr)
|
||||
frame->release();
|
||||
}
|
||||
|
||||
|
|
|
@ -280,38 +280,38 @@ public:
|
|||
void convertFrameCoordinates(const ObserverFrame* newFrame);
|
||||
|
||||
private:
|
||||
double simTime;
|
||||
double simTime{ 0.0 };
|
||||
|
||||
// Position, orientation, and velocity in the observer's reference frame
|
||||
UniversalCoord position;
|
||||
Eigen::Quaterniond orientation;
|
||||
Eigen::Vector3d velocity;
|
||||
Eigen::Vector3d angularVelocity;
|
||||
UniversalCoord position{ 0.0, 0.0, 0.0 };
|
||||
Eigen::Quaterniond orientation{ Eigen::Quaternionf::Identity() };
|
||||
Eigen::Vector3d velocity{ 0.0, 0.0, 0.0 };
|
||||
Eigen::Vector3d angularVelocity{ 0.0, 0.0, 0.0 };
|
||||
|
||||
// Position and orientation in universal coordinates, derived from the
|
||||
// equivalent quantities in the observer reference frame.
|
||||
UniversalCoord positionUniv;
|
||||
UniversalCoord positionUniv;
|
||||
Eigen::Quaterniond orientationUniv;
|
||||
|
||||
ObserverFrame* frame;
|
||||
ObserverFrame* frame{ nullptr };
|
||||
|
||||
double realTime;
|
||||
double realTime{ 0.0 };
|
||||
|
||||
double targetSpeed;
|
||||
Eigen::Vector3d targetVelocity;
|
||||
Eigen::Vector3d initialVelocity;
|
||||
double beginAccelTime;
|
||||
double targetSpeed{ 0.0 };
|
||||
Eigen::Vector3d targetVelocity{ 0.0, 0.0, 0.0 };
|
||||
Eigen::Vector3d initialVelocity{ 0.0, 0.0, 0.0 };
|
||||
double beginAccelTime{ 0.0 };
|
||||
|
||||
ObserverMode observerMode;
|
||||
JourneyParams journey;
|
||||
Selection trackObject;
|
||||
ObserverMode observerMode{ Free };
|
||||
JourneyParams journey;
|
||||
Selection trackObject;
|
||||
|
||||
Eigen::Quaterniond trackingOrientation; // orientation prior to selecting tracking
|
||||
Eigen::Quaterniond trackingOrientation{ Eigen::Quaternionf::Identity() }; // orientation prior to selecting tracking
|
||||
|
||||
float fov;
|
||||
bool reverseFlag;
|
||||
float fov{ (float) (PI / 4.0) };
|
||||
bool reverseFlag{ false };
|
||||
|
||||
uint32 locationFilter;
|
||||
uint32 locationFilter{ ~0u };
|
||||
std::string displayedSurface;
|
||||
};
|
||||
|
||||
|
|
|
@ -170,10 +170,10 @@ enum
|
|||
template <class OBJ, class PREC>
|
||||
inline DynamicOctree<OBJ, PREC>::DynamicOctree(const Eigen::Matrix<PREC, 3, 1>& cellCenterPos,
|
||||
const float exclusionFactor):
|
||||
_children (NULL),
|
||||
_children (nullptr),
|
||||
cellCenterPos (cellCenterPos),
|
||||
exclusionFactor(exclusionFactor),
|
||||
_objects (NULL)
|
||||
_objects (nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ inline DynamicOctree<OBJ, PREC>::DynamicOctree(const Eigen::Matrix<PREC, 3, 1>&
|
|||
template <class OBJ, class PREC>
|
||||
inline DynamicOctree<OBJ, PREC>::~DynamicOctree()
|
||||
{
|
||||
if (_children != NULL)
|
||||
if (_children != nullptr)
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
|
@ -209,10 +209,10 @@ inline void DynamicOctree<OBJ, PREC>::insertObject(const OBJ& obj, const PREC sc
|
|||
// object into a child node. This is done in order
|
||||
// to avoid having the octree degenerate into one object
|
||||
// per node.
|
||||
if (_children == NULL)
|
||||
if (_children == nullptr)
|
||||
{
|
||||
// Make sure that there's enough room left in this node
|
||||
if (_objects != NULL && _objects->size() >= DynamicOctree<OBJ, PREC>::SPLIT_THRESHOLD)
|
||||
if (_objects != nullptr && _objects->size() >= DynamicOctree<OBJ, PREC>::SPLIT_THRESHOLD)
|
||||
split(scale * 0.5f);
|
||||
add(obj);
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ inline void DynamicOctree<OBJ, PREC>::insertObject(const OBJ& obj, const PREC sc
|
|||
template <class OBJ, class PREC>
|
||||
inline void DynamicOctree<OBJ, PREC>::add(const OBJ& obj)
|
||||
{
|
||||
if (_objects == NULL)
|
||||
if (_objects == nullptr)
|
||||
_objects = new ObjectList;
|
||||
|
||||
_objects->push_back(&obj);
|
||||
|
@ -292,7 +292,7 @@ inline void DynamicOctree<OBJ, PREC>::rebuildAndSort(StaticOctree<OBJ, PREC>*& _
|
|||
{
|
||||
OBJ* _firstObject = _sortedObjects;
|
||||
|
||||
if (_objects != NULL)
|
||||
if (_objects != nullptr)
|
||||
for (typename ObjectList::const_iterator iter = _objects->begin(); iter != _objects->end(); ++iter)
|
||||
{
|
||||
*_sortedObjects++ = **iter;
|
||||
|
@ -301,7 +301,7 @@ inline void DynamicOctree<OBJ, PREC>::rebuildAndSort(StaticOctree<OBJ, PREC>*& _
|
|||
unsigned int nObjects = (unsigned int) (_sortedObjects - _firstObject);
|
||||
_staticNode = new StaticOctree<OBJ, PREC>(cellCenterPos, exclusionFactor, _firstObject, nObjects);
|
||||
|
||||
if (_children != NULL)
|
||||
if (_children != nullptr)
|
||||
{
|
||||
_staticNode->_children = new StaticOctree<OBJ, PREC>*[8];
|
||||
|
||||
|
@ -321,7 +321,7 @@ inline StaticOctree<OBJ, PREC>::StaticOctree(const Eigen::Matrix<PREC, 3, 1>& ce
|
|||
const float exclusionFactor,
|
||||
OBJ* _firstObject,
|
||||
unsigned int nObjects):
|
||||
_children (NULL),
|
||||
_children (nullptr),
|
||||
cellCenterPos (cellCenterPos),
|
||||
exclusionFactor(exclusionFactor),
|
||||
_firstObject (_firstObject),
|
||||
|
@ -333,7 +333,7 @@ inline StaticOctree<OBJ, PREC>::StaticOctree(const Eigen::Matrix<PREC, 3, 1>& ce
|
|||
template <class OBJ, class PREC>
|
||||
inline StaticOctree<OBJ, PREC>::~StaticOctree()
|
||||
{
|
||||
if (_children != NULL)
|
||||
if (_children != nullptr)
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
delete _children[i];
|
||||
|
@ -349,7 +349,7 @@ inline int StaticOctree<OBJ, PREC>::countChildren() const
|
|||
int count = 0;
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
count += _children != NULL ? 1 + _children[i]->countChildren() : 0;
|
||||
count += _children != nullptr ? 1 + _children[i]->countChildren() : 0;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ inline int StaticOctree<OBJ, PREC>::countObjects() const
|
|||
{
|
||||
int count = nObjects;
|
||||
|
||||
if (_children != NULL)
|
||||
if (_children != nullptr)
|
||||
for (int i = 0; i < 8; ++i)
|
||||
count += _children[i]->countObjects();
|
||||
|
||||
|
@ -387,7 +387,7 @@ void StaticOctree<OBJ, PREC>::computeStatistics(std::vector<OctreeLevelStatistic
|
|||
stats[level].objectCount += nObjects;
|
||||
stats[level].size = 0.0;
|
||||
|
||||
if (_children != NULL)
|
||||
if (_children != nullptr)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
_children[i]->computeStatistics(stats, level + 1);
|
||||
|
|
|
@ -23,11 +23,6 @@ using namespace Eigen;
|
|||
using namespace std;
|
||||
|
||||
|
||||
OpenCluster::OpenCluster()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const char* OpenCluster::getType() const
|
||||
{
|
||||
return "Open cluster";
|
||||
|
@ -67,11 +62,11 @@ bool OpenCluster::load(AssociativeArray* params, const string& resPath)
|
|||
}
|
||||
|
||||
|
||||
void OpenCluster::render(const GLContext&,
|
||||
const Vector3f&,
|
||||
const Quaternionf&,
|
||||
float,
|
||||
float)
|
||||
void OpenCluster::render(const GLContext& /*unused*/,
|
||||
const Vector3f& /*unused*/,
|
||||
const Quaternionf& /*unused*/,
|
||||
float /*unused*/,
|
||||
float /*unused*/)
|
||||
{
|
||||
// Nothing to do right now; open clusters are only visible as their
|
||||
// constituent stars and a label when labels are turned on. A good idea
|
||||
|
|
|
@ -19,7 +19,7 @@ class OpenCluster : public DeepSkyObject
|
|||
public:
|
||||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||
|
||||
OpenCluster();
|
||||
OpenCluster() = default;
|
||||
|
||||
virtual const char* getType() const;
|
||||
virtual void setType(const std::string&);
|
||||
|
|
|
@ -19,24 +19,11 @@ using namespace std;
|
|||
|
||||
|
||||
Overlay::Overlay() :
|
||||
ostream(&sbuf),
|
||||
windowWidth(1),
|
||||
windowHeight(1),
|
||||
font(NULL),
|
||||
useTexture(false),
|
||||
fontChanged(false),
|
||||
textBlock(0),
|
||||
xoffset(0.0f),
|
||||
yoffset(0.0f)
|
||||
ostream(&sbuf)
|
||||
{
|
||||
sbuf.setOverlay(this);
|
||||
}
|
||||
|
||||
Overlay::~Overlay()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Overlay::begin()
|
||||
{
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
|
@ -100,7 +87,7 @@ void Overlay::endText()
|
|||
|
||||
void Overlay::print(wchar_t c)
|
||||
{
|
||||
if (font != NULL)
|
||||
if (font != nullptr)
|
||||
{
|
||||
if (!useTexture || fontChanged)
|
||||
{
|
||||
|
@ -132,7 +119,7 @@ void Overlay::print(wchar_t c)
|
|||
|
||||
void Overlay::print(char c)
|
||||
{
|
||||
if (font != NULL)
|
||||
if (font != nullptr)
|
||||
{
|
||||
if (!useTexture || fontChanged)
|
||||
{
|
||||
|
@ -216,11 +203,9 @@ void Overlay::rect(float x, float y, float w, float h, bool fill)
|
|||
//
|
||||
// OverlayStreamBuf implementation
|
||||
//
|
||||
OverlayStreamBuf::OverlayStreamBuf() :
|
||||
overlay(NULL),
|
||||
decodeState(UTF8DecodeStart)
|
||||
OverlayStreamBuf::OverlayStreamBuf()
|
||||
{
|
||||
setbuf(0, 0);
|
||||
setbuf(nullptr, 0);
|
||||
};
|
||||
|
||||
|
||||
|
@ -232,7 +217,7 @@ void OverlayStreamBuf::setOverlay(Overlay* o)
|
|||
|
||||
int OverlayStreamBuf::overflow(int c)
|
||||
{
|
||||
if (overlay != NULL)
|
||||
if (overlay != nullptr)
|
||||
{
|
||||
switch (decodeState)
|
||||
{
|
||||
|
|
|
@ -37,9 +37,9 @@ class OverlayStreamBuf : public std::streambuf
|
|||
};
|
||||
|
||||
private:
|
||||
Overlay* overlay;
|
||||
Overlay* overlay{ nullptr };
|
||||
|
||||
UTF8DecodeState decodeState;
|
||||
UTF8DecodeState decodeState{ UTF8DecodeStart };
|
||||
wchar_t decodedChar;
|
||||
unsigned int decodeShift;
|
||||
};
|
||||
|
@ -49,7 +49,7 @@ class Overlay : public std::ostream
|
|||
{
|
||||
public:
|
||||
Overlay();
|
||||
~Overlay();
|
||||
~Overlay() = default;
|
||||
|
||||
void begin();
|
||||
void end();
|
||||
|
@ -73,15 +73,15 @@ class Overlay : public std::ostream
|
|||
#endif
|
||||
|
||||
private:
|
||||
int windowWidth;
|
||||
int windowHeight;
|
||||
TextureFont* font;
|
||||
bool useTexture;
|
||||
bool fontChanged;
|
||||
int textBlock;
|
||||
int windowWidth{ 1 };
|
||||
int windowHeight{ 1 };
|
||||
TextureFont* font{ nullptr };
|
||||
bool useTexture{ false };
|
||||
bool fontChanged{ false };
|
||||
int textBlock{ 0 };
|
||||
|
||||
float xoffset;
|
||||
float yoffset;
|
||||
float xoffset{ 0.0f };
|
||||
float yoffset{ 0.0f };
|
||||
|
||||
OverlayStreamBuf sbuf;
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -22,7 +22,7 @@ Value::Value(double d)
|
|||
data.d = d;
|
||||
}
|
||||
|
||||
Value::Value(string s)
|
||||
Value::Value(const string& s)
|
||||
{
|
||||
type = StringType;
|
||||
data.s = new string(s);
|
||||
|
@ -54,7 +54,7 @@ Value::~Value()
|
|||
}
|
||||
else if (type == ArrayType)
|
||||
{
|
||||
if (data.a != NULL)
|
||||
if (data.a != nullptr)
|
||||
{
|
||||
for (unsigned int i = 0; i < data.a->size(); i++)
|
||||
delete (*data.a)[i];
|
||||
|
@ -63,7 +63,7 @@ Value::~Value()
|
|||
}
|
||||
else if (type == HashType)
|
||||
{
|
||||
if (data.h != NULL)
|
||||
if (data.h != nullptr)
|
||||
{
|
||||
#if 0
|
||||
Hash::iterator iter = data.h->begin();
|
||||
|
@ -128,13 +128,13 @@ ValueArray* Parser::readArray()
|
|||
if (tok != Tokenizer::TokenBeginArray)
|
||||
{
|
||||
tokenizer->pushBack();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ValueArray* array = new ValueArray();
|
||||
auto* array = new ValueArray();
|
||||
|
||||
Value* v = readValue();
|
||||
while (v != NULL)
|
||||
while (v != nullptr)
|
||||
{
|
||||
array->insert(array->end(), v);
|
||||
v = readValue();
|
||||
|
@ -145,7 +145,7 @@ ValueArray* Parser::readArray()
|
|||
{
|
||||
tokenizer->pushBack();
|
||||
delete array;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return array;
|
||||
|
@ -158,10 +158,10 @@ Hash* Parser::readHash()
|
|||
if (tok != Tokenizer::TokenBeginGroup)
|
||||
{
|
||||
tokenizer->pushBack();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Hash* hash = new Hash();
|
||||
auto* hash = new Hash();
|
||||
|
||||
tok = tokenizer->nextToken();
|
||||
while (tok != Tokenizer::TokenEndGroup)
|
||||
|
@ -170,7 +170,7 @@ Hash* Parser::readHash()
|
|||
{
|
||||
tokenizer->pushBack();
|
||||
delete hash;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
string name = tokenizer->getNameValue();
|
||||
|
||||
|
@ -179,10 +179,10 @@ Hash* Parser::readHash()
|
|||
#endif
|
||||
|
||||
Value* value = readValue();
|
||||
if (value == NULL)
|
||||
if (value == nullptr)
|
||||
{
|
||||
delete hash;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
hash->addValue(name, *value);
|
||||
|
@ -272,15 +272,15 @@ Value* Parser::readValue()
|
|||
else
|
||||
{
|
||||
tokenizer->pushBack();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
case Tokenizer::TokenBeginArray:
|
||||
tokenizer->pushBack();
|
||||
{
|
||||
ValueArray* array = readArray();
|
||||
if (array == NULL)
|
||||
return NULL;
|
||||
if (array == nullptr)
|
||||
return nullptr;
|
||||
else
|
||||
return new Value(array);
|
||||
}
|
||||
|
@ -289,23 +289,19 @@ Value* Parser::readValue()
|
|||
tokenizer->pushBack();
|
||||
{
|
||||
Hash* hash = readHash();
|
||||
if (hash == NULL)
|
||||
return NULL;
|
||||
if (hash == nullptr)
|
||||
return nullptr;
|
||||
else
|
||||
return new Value(hash);
|
||||
}
|
||||
|
||||
default:
|
||||
tokenizer->pushBack();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AssociativeArray::AssociativeArray()
|
||||
{
|
||||
}
|
||||
|
||||
AssociativeArray::~AssociativeArray()
|
||||
{
|
||||
#if 0
|
||||
|
@ -316,20 +312,20 @@ AssociativeArray::~AssociativeArray()
|
|||
iter++;
|
||||
}
|
||||
#endif
|
||||
for (map<string, Value*>::iterator iter = assoc.begin(); iter != assoc.end(); iter++)
|
||||
delete iter->second;
|
||||
for (const auto iter : assoc)
|
||||
delete iter.second;
|
||||
}
|
||||
|
||||
Value* AssociativeArray::getValue(string key) const
|
||||
Value* AssociativeArray::getValue(const string& key) const
|
||||
{
|
||||
map<string, Value*>::const_iterator iter = assoc.find(key);
|
||||
if (iter == assoc.end())
|
||||
return NULL;
|
||||
else
|
||||
return iter->second;
|
||||
return nullptr;
|
||||
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
void AssociativeArray::addValue(string key, Value& val)
|
||||
void AssociativeArray::addValue(const string& key, Value& val)
|
||||
{
|
||||
assoc.insert(map<string, Value*>::value_type(key, &val));
|
||||
}
|
||||
|
@ -337,11 +333,10 @@ void AssociativeArray::addValue(string key, Value& val)
|
|||
bool AssociativeArray::getNumber(const string& key, double& val) const
|
||||
{
|
||||
Value* v = getValue(key);
|
||||
if (v == NULL || v->getType() != Value::NumberType)
|
||||
if (v == nullptr || v->getType() != Value::NumberType)
|
||||
return false;
|
||||
|
||||
val = v->getNumber();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -350,14 +345,10 @@ bool AssociativeArray::getNumber(const string& key, float& val) const
|
|||
double dval;
|
||||
|
||||
if (!getNumber(key, dval))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
val = (float) dval;
|
||||
return true;
|
||||
}
|
||||
|
||||
val = (float) dval;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssociativeArray::getNumber(const string& key, int& val) const
|
||||
|
@ -365,14 +356,10 @@ bool AssociativeArray::getNumber(const string& key, int& val) const
|
|||
double ival;
|
||||
|
||||
if (!getNumber(key, ival))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
val = (int) ival;
|
||||
return true;
|
||||
}
|
||||
|
||||
val = (int) ival;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssociativeArray::getNumber(const string& key, uint32& val) const
|
||||
|
@ -380,42 +367,36 @@ bool AssociativeArray::getNumber(const string& key, uint32& val) const
|
|||
double ival;
|
||||
|
||||
if (!getNumber(key, ival))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
val = (uint32) ival;
|
||||
return true;
|
||||
}
|
||||
|
||||
val = (uint32) ival;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssociativeArray::getString(const string& key, string& val) const
|
||||
{
|
||||
Value* v = getValue(key);
|
||||
if (v == NULL || v->getType() != Value::StringType)
|
||||
if (v == nullptr || v->getType() != Value::StringType)
|
||||
return false;
|
||||
|
||||
val = v->getString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssociativeArray::getBoolean(const string& key, bool& val) const
|
||||
{
|
||||
Value* v = getValue(key);
|
||||
if (v == NULL || v->getType() != Value::BooleanType)
|
||||
if (v == nullptr || v->getType() != Value::BooleanType)
|
||||
return false;
|
||||
|
||||
val = v->getBoolean();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssociativeArray::getVector(const string& key, Vec3d& val) const
|
||||
{
|
||||
Value* v = getValue(key);
|
||||
if (v == NULL || v->getType() != Value::ArrayType)
|
||||
if (v == nullptr || v->getType() != Value::ArrayType)
|
||||
return false;
|
||||
|
||||
ValueArray* arr = v->getArray();
|
||||
|
@ -432,14 +413,13 @@ bool AssociativeArray::getVector(const string& key, Vec3d& val) const
|
|||
return false;
|
||||
|
||||
val = Vec3d(x->getNumber(), y->getNumber(), z->getNumber());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssociativeArray::getVector(const string& key, Vector3d& val) const
|
||||
{
|
||||
Value* v = getValue(key);
|
||||
if (v == NULL || v->getType() != Value::ArrayType)
|
||||
if (v == nullptr || v->getType() != Value::ArrayType)
|
||||
return false;
|
||||
|
||||
ValueArray* arr = v->getArray();
|
||||
|
@ -456,7 +436,6 @@ bool AssociativeArray::getVector(const string& key, Vector3d& val) const
|
|||
return false;
|
||||
|
||||
val = Vector3d(x->getNumber(), y->getNumber(), z->getNumber());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -468,7 +447,6 @@ bool AssociativeArray::getVector(const string& key, Vec3f& val) const
|
|||
return false;
|
||||
|
||||
val = Vec3f((float) vecVal.x, (float) vecVal.y, (float) vecVal.z);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -481,7 +459,6 @@ bool AssociativeArray::getVector(const string& key, Vector3f& val) const
|
|||
return false;
|
||||
|
||||
val = vecVal.cast<float>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -490,7 +467,7 @@ bool AssociativeArray::getVector(const string& key, Vector3f& val) const
|
|||
bool AssociativeArray::getRotation(const string& key, Quatf& val) const
|
||||
{
|
||||
Value* v = getValue(key);
|
||||
if (v == NULL || v->getType() != Value::ArrayType)
|
||||
if (v == nullptr || v->getType() != Value::ArrayType)
|
||||
return false;
|
||||
|
||||
ValueArray* arr = v->getArray();
|
||||
|
@ -537,7 +514,7 @@ bool AssociativeArray::getRotation(const string& key, Quatf& val) const
|
|||
bool AssociativeArray::getRotation(const string& key, Eigen::Quaternionf& val) const
|
||||
{
|
||||
Value* v = getValue(key);
|
||||
if (v == NULL || v->getType() != Value::ArrayType)
|
||||
if (v == nullptr || v->getType() != Value::ArrayType)
|
||||
return false;
|
||||
|
||||
ValueArray* arr = v->getArray();
|
||||
|
@ -578,7 +555,6 @@ bool AssociativeArray::getColor(const string& key, Color& val) const
|
|||
return false;
|
||||
|
||||
val = Color((float) vecVal.x, (float) vecVal.y, (float) vecVal.z);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -753,7 +729,6 @@ bool AssociativeArray::getLengthVector(const string& key, Eigen::Vector3f& val,
|
|||
return false;
|
||||
|
||||
val = vecVal.cast<float>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -793,7 +768,6 @@ bool AssociativeArray::getSphericalTuple(const string& key, Vector3f& val) const
|
|||
return false;
|
||||
|
||||
val = vecVal.cast<float>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ typedef map<string, Value*>::const_iterator HashIterator;
|
|||
class AssociativeArray
|
||||
{
|
||||
public:
|
||||
AssociativeArray();
|
||||
AssociativeArray() = default;
|
||||
~AssociativeArray();
|
||||
|
||||
Value* getValue(string) const;
|
||||
void addValue(string, Value&);
|
||||
Value* getValue(const std::string&) const;
|
||||
void addValue(const std::string&, Value&);
|
||||
|
||||
bool getNumber(const std::string&, double&) const;
|
||||
bool getNumber(const std::string&, float&) const;
|
||||
|
@ -87,7 +87,7 @@ public:
|
|||
};
|
||||
|
||||
Value(double);
|
||||
Value(string);
|
||||
Value(const string&);
|
||||
Value(ValueArray*);
|
||||
Value(Hash*);
|
||||
Value(bool);
|
||||
|
|
|
@ -90,10 +90,7 @@ static const uint64 M = ((uint64) 1 << 48) - 1;
|
|||
class LCGRandomGenerator
|
||||
{
|
||||
public:
|
||||
LCGRandomGenerator() :
|
||||
previous(0)
|
||||
{
|
||||
}
|
||||
LCGRandomGenerator() : previous(0) = default;
|
||||
|
||||
LCGRandomGenerator(uint64 seed) :
|
||||
previous(seed)
|
||||
|
@ -240,8 +237,8 @@ ParticleEmitter::ParticleEmitter() :
|
|||
m_startSize(1.0f),
|
||||
m_endColor(1.0f, 1.0f, 1.0f, 0.0f),
|
||||
m_endSize(1.0f),
|
||||
m_positionGenerator(NULL),
|
||||
m_velocityGenerator(NULL),
|
||||
m_positionGenerator(nullptr),
|
||||
m_velocityGenerator(nullptr),
|
||||
m_acceleration(0.0f, 0.0f, 0.0f),
|
||||
m_nonZeroAcceleration(false),
|
||||
m_minRotationRate(0.0f),
|
||||
|
@ -331,13 +328,13 @@ ParticleEmitter::render(double tsec,
|
|||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
Texture* texture = NULL;
|
||||
Texture* texture = nullptr;
|
||||
if (m_texture != InvalidResource)
|
||||
{
|
||||
texture = GetTextureManager()->find(m_texture);
|
||||
}
|
||||
|
||||
if (texture != NULL)
|
||||
if (texture != nullptr)
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
texture->bind();
|
||||
|
@ -355,9 +352,9 @@ ParticleEmitter::render(double tsec,
|
|||
|
||||
double emissionInterval = 1.0 / m_rate;
|
||||
double dserial = std::fmod(t * m_rate, (double) (1 << 31));
|
||||
int serial = (int) (dserial);
|
||||
auto serial = (int) (dserial);
|
||||
double age = (dserial - serial) * emissionInterval;
|
||||
float invLifetime = (float) (1.0 / m_lifetime);
|
||||
auto invLifetime = (float) (1.0 / m_lifetime);
|
||||
|
||||
double maxAge = m_lifetime;
|
||||
if (startBounded)
|
||||
|
@ -367,7 +364,7 @@ ParticleEmitter::render(double tsec,
|
|||
|
||||
if (endBounded && tsec > m_endTime)
|
||||
{
|
||||
int skipParticles = (int) ((tsec - m_endTime) * m_rate);
|
||||
auto skipParticles = (int) ((tsec - m_endTime) * m_rate);
|
||||
serial -= skipParticles;
|
||||
age += skipParticles * emissionInterval;
|
||||
}
|
||||
|
@ -460,8 +457,8 @@ ParticleEmitter::createMaterial()
|
|||
#define STRUCT_OFFSET(s, memberName) ((uint32) (reinterpret_cast<char*>(&(s).memberName) - reinterpret_cast<char*>(&(s))))
|
||||
|
||||
ParticleSystem::ParticleSystem() :
|
||||
m_vertexDesc(NULL),
|
||||
m_vertexData(NULL),
|
||||
m_vertexDesc(nullptr),
|
||||
m_vertexData(nullptr),
|
||||
m_particleCapacity(0),
|
||||
m_particleCount(0)
|
||||
{
|
||||
|
@ -481,11 +478,8 @@ ParticleSystem::ParticleSystem() :
|
|||
|
||||
ParticleSystem::~ParticleSystem()
|
||||
{
|
||||
for (list<ParticleEmitter*>::const_iterator iter = m_emitterList.begin();
|
||||
iter != m_emitterList.end(); iter++)
|
||||
{
|
||||
delete (*iter);
|
||||
}
|
||||
for (const auto emitter : m_emitterList)
|
||||
delete emitter;
|
||||
|
||||
delete[] m_vertexData;
|
||||
delete m_vertexDesc;
|
||||
|
@ -497,10 +491,9 @@ ParticleSystem::render(RenderContext& rc, double tsec)
|
|||
{
|
||||
rc.setVertexArrays(*m_vertexDesc, m_vertexData);
|
||||
|
||||
for (list<ParticleEmitter*>::const_iterator iter = m_emitterList.begin();
|
||||
iter != m_emitterList.end(); iter++)
|
||||
for (const auto emitter : m_emitterList)
|
||||
{
|
||||
(*iter)->render(tsec, rc, m_vertexData, m_particleCapacity);
|
||||
emitter->render(tsec, rc, m_vertexData, m_particleCapacity);
|
||||
}
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
ParticleEmitter();
|
||||
~ParticleEmitter();
|
||||
|
||||
void render(double tsec, RenderContext& rc, ParticleVertex* particleBuffer, unsigned int bufferCapacity) const;
|
||||
void render(double tsec, RenderContext& rc, ParticleVertex* particleBuffer, unsigned int particleBufferCapacity) const;
|
||||
|
||||
void setAcceleration(const Eigen::Vector3f& acceleration);
|
||||
void createMaterial();
|
||||
|
@ -97,7 +97,7 @@ class ParticleSystem : public Geometry
|
|||
ParticleSystem();
|
||||
virtual ~ParticleSystem();
|
||||
|
||||
virtual void render(RenderContext& rc, double t = 0.0);
|
||||
virtual void render(RenderContext& rc, double tsec = 0.0);
|
||||
virtual bool pick(const Ray3d& r, double& distance) const;
|
||||
virtual bool isOpaque() const;
|
||||
|
||||
|
@ -121,8 +121,8 @@ class LCGRandomGenerator;
|
|||
class VectorGenerator
|
||||
{
|
||||
public:
|
||||
VectorGenerator() {};
|
||||
virtual ~VectorGenerator() {};
|
||||
VectorGenerator() = default;
|
||||
virtual ~VectorGenerator() = default;
|
||||
virtual Eigen::Vector3f generate(LCGRandomGenerator& gen) const = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -34,15 +34,10 @@ ParticleSystemLoader::ParticleSystemLoader(istream& in) :
|
|||
}
|
||||
|
||||
|
||||
ParticleSystemLoader::~ParticleSystemLoader()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ParticleSystem*
|
||||
ParticleSystemLoader::load()
|
||||
{
|
||||
ParticleSystem* particleSystem = new ParticleSystem();
|
||||
auto* particleSystem = new ParticleSystem();
|
||||
|
||||
while (m_tokenizer.nextToken() != Tokenizer::TokenEnd)
|
||||
{
|
||||
|
@ -52,7 +47,7 @@ ParticleSystemLoader::load()
|
|||
{
|
||||
raiseError("Error parsing particle system");
|
||||
delete particleSystem;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
objType = m_tokenizer.getNameValue();
|
||||
|
@ -63,26 +58,26 @@ ParticleSystemLoader::load()
|
|||
raiseError(stream.str());
|
||||
|
||||
delete particleSystem;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Value* objParamsValue = m_parser.readValue();
|
||||
if (objParamsValue == NULL || objParamsValue->getType() != Value::HashType)
|
||||
if (objParamsValue == nullptr || objParamsValue->getType() != Value::HashType)
|
||||
{
|
||||
raiseError("Error parsing particle system");
|
||||
|
||||
delete particleSystem;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Hash* objParams = objParamsValue->getHash();
|
||||
if (objType == "Emitter")
|
||||
{
|
||||
ParticleEmitter* emitter = parseEmitter(objParams);
|
||||
if (emitter == NULL)
|
||||
if (emitter == nullptr)
|
||||
{
|
||||
delete particleSystem;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
particleSystem->addEmitter(emitter);
|
||||
|
@ -102,14 +97,14 @@ ParticleSystemLoader::parseGenerator(Hash* params)
|
|||
return new ConstantGenerator(constantValue);
|
||||
}
|
||||
|
||||
Value* generatorValue = NULL;
|
||||
Value* generatorValue = nullptr;
|
||||
generatorValue = params->getValue("Box");
|
||||
if (generatorValue != NULL)
|
||||
if (generatorValue != nullptr)
|
||||
{
|
||||
if (generatorValue->getType() != Value::HashType)
|
||||
{
|
||||
raiseError("Error in Box syntax");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Hash* boxParams = generatorValue->getHash();
|
||||
|
@ -123,12 +118,12 @@ ParticleSystemLoader::parseGenerator(Hash* params)
|
|||
}
|
||||
|
||||
generatorValue = params->getValue("Line");
|
||||
if (generatorValue != NULL)
|
||||
if (generatorValue != nullptr)
|
||||
{
|
||||
if (generatorValue->getType() != Value::HashType)
|
||||
{
|
||||
raiseError("Error in Line syntax");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Hash* lineParams = generatorValue->getHash();
|
||||
|
@ -142,12 +137,12 @@ ParticleSystemLoader::parseGenerator(Hash* params)
|
|||
}
|
||||
|
||||
generatorValue = params->getValue("EllipsoidSurface");
|
||||
if (generatorValue != NULL)
|
||||
if (generatorValue != nullptr)
|
||||
{
|
||||
if (generatorValue->getType() != Value::HashType)
|
||||
{
|
||||
raiseError("Error in EllipsoidSurface syntax");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Hash* ellipsoidSurfaceParams = generatorValue->getHash();
|
||||
|
@ -161,12 +156,12 @@ ParticleSystemLoader::parseGenerator(Hash* params)
|
|||
}
|
||||
|
||||
generatorValue = params->getValue("Cone");
|
||||
if (generatorValue != NULL)
|
||||
if (generatorValue != nullptr)
|
||||
{
|
||||
if (generatorValue->getType() != Value::HashType)
|
||||
{
|
||||
raiseError("Error in Cone syntax");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Hash* coneParams = generatorValue->getHash();
|
||||
|
@ -184,12 +179,12 @@ ParticleSystemLoader::parseGenerator(Hash* params)
|
|||
}
|
||||
|
||||
generatorValue = params->getValue("GaussianDisc");
|
||||
if (generatorValue != NULL)
|
||||
if (generatorValue != nullptr)
|
||||
{
|
||||
if (generatorValue->getType() != Value::HashType)
|
||||
{
|
||||
raiseError("Error in GaussianDisc syntax");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Hash* gaussianDiscParams = generatorValue->getHash();
|
||||
|
@ -202,7 +197,7 @@ ParticleSystemLoader::parseGenerator(Hash* params)
|
|||
|
||||
raiseError("Missing generator for emitter");
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -236,9 +231,9 @@ ParticleSystemLoader::parseEmitter(Hash* params)
|
|||
params->getColor("EndColor", endColor);
|
||||
params->getNumber("EndOpacity", endOpacity);
|
||||
|
||||
VectorGenerator* initialPositionGenerator = NULL;
|
||||
VectorGenerator* initialPositionGenerator = nullptr;
|
||||
Value* positionValue = params->getValue("InitialPosition");
|
||||
if (positionValue == NULL)
|
||||
if (positionValue == nullptr)
|
||||
{
|
||||
initialPositionGenerator = new ConstantGenerator(Vector3f::Zero());
|
||||
}
|
||||
|
@ -254,14 +249,14 @@ ParticleSystemLoader::parseEmitter(Hash* params)
|
|||
}
|
||||
}
|
||||
|
||||
if (initialPositionGenerator == NULL)
|
||||
if (initialPositionGenerator == nullptr)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
VectorGenerator* initialVelocityGenerator = NULL;
|
||||
VectorGenerator* initialVelocityGenerator = nullptr;
|
||||
Value* velocityValue = params->getValue("InitialVelocity");
|
||||
if (velocityValue == NULL)
|
||||
if (velocityValue == nullptr)
|
||||
{
|
||||
initialVelocityGenerator = new ConstantGenerator(Vector3f::Zero());
|
||||
}
|
||||
|
@ -277,10 +272,10 @@ ParticleSystemLoader::parseEmitter(Hash* params)
|
|||
}
|
||||
}
|
||||
|
||||
if (initialVelocityGenerator == NULL)
|
||||
if (initialVelocityGenerator == nullptr)
|
||||
{
|
||||
delete initialPositionGenerator;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Vector3f acceleration;
|
||||
|
@ -296,7 +291,7 @@ ParticleSystemLoader::parseEmitter(Hash* params)
|
|||
params->getNumber("MinRotationRate", minRotationRate);
|
||||
params->getNumber("MaxRotationRate", maxRotationRate);
|
||||
|
||||
ParticleEmitter* emitter = new ParticleEmitter();
|
||||
auto* emitter = new ParticleEmitter();
|
||||
emitter->m_texture = textureHandle;
|
||||
emitter->m_rate = (float) rate;
|
||||
emitter->m_lifetime = (float) lifetime;
|
||||
|
@ -348,14 +343,14 @@ ParticleSystemLoader::getTexturePath() const
|
|||
ParticleSystem*
|
||||
LoadParticleSystem(istream& in, const string& texPath)
|
||||
{
|
||||
ParticleSystemLoader* loader = new ParticleSystemLoader(in);
|
||||
if (loader == NULL)
|
||||
return NULL;
|
||||
auto* loader = new ParticleSystemLoader(in);
|
||||
if (loader == nullptr)
|
||||
return nullptr;
|
||||
|
||||
loader->setTexturePath(texPath);
|
||||
|
||||
ParticleSystem* particleSystem = loader->load();
|
||||
if (particleSystem == NULL)
|
||||
if (particleSystem == nullptr)
|
||||
cerr << "Error in particle system file: " << loader->getErrorMessage() << '\n';
|
||||
|
||||
delete loader;
|
||||
|
|
|
@ -25,7 +25,7 @@ class ParticleSystemLoader
|
|||
{
|
||||
public:
|
||||
ParticleSystemLoader(std::istream&);
|
||||
~ParticleSystemLoader();
|
||||
~ParticleSystemLoader() = default;
|
||||
|
||||
ParticleSystem* load();
|
||||
VectorGenerator* parseGenerator(Hash* params);
|
||||
|
|
|
@ -24,29 +24,20 @@ using namespace Eigen;
|
|||
|
||||
|
||||
unsigned int PlanetographicGrid::circleSubdivisions = 100;
|
||||
float* PlanetographicGrid::xyCircle = NULL;
|
||||
float* PlanetographicGrid::xzCircle = NULL;
|
||||
float* PlanetographicGrid::xyCircle = nullptr;
|
||||
float* PlanetographicGrid::xzCircle = nullptr;
|
||||
|
||||
|
||||
PlanetographicGrid::PlanetographicGrid(const Body& _body) :
|
||||
body(_body),
|
||||
minLongitudeStep(10.0f),
|
||||
minLatitudeStep(10.0f),
|
||||
longitudeConvention(Westward),
|
||||
northDirection(NorthNormal)
|
||||
body(_body)
|
||||
{
|
||||
if (xyCircle == NULL)
|
||||
if (xyCircle == nullptr)
|
||||
InitializeGeometry();
|
||||
setTag("planetographic grid");
|
||||
setIAULongLatConvention();
|
||||
}
|
||||
|
||||
|
||||
PlanetographicGrid::~PlanetographicGrid()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void longLatLabel(const string& labelText,
|
||||
double longitude,
|
||||
double latitude,
|
||||
|
@ -86,7 +77,7 @@ static void longLatLabel(const string& labelText,
|
|||
double z = viewNormal.dot(labelPos);
|
||||
labelPos *= planetZ / z;
|
||||
|
||||
renderer->addObjectAnnotation(NULL, labelText,
|
||||
renderer->addObjectAnnotation(nullptr, labelText,
|
||||
Renderer::PlanetographicGridLabelColor,
|
||||
labelPos.cast<float>());
|
||||
}
|
||||
|
@ -150,7 +141,7 @@ PlanetographicGrid::render(Renderer* renderer,
|
|||
for (float latitude = -90.0f + latitudeStep; latitude < 90.0f; latitude += latitudeStep)
|
||||
{
|
||||
float phi = degToRad(latitude);
|
||||
float r = (float) cos(phi);
|
||||
auto r = (float) std::cos(phi);
|
||||
|
||||
if (latitude == 0.0f)
|
||||
{
|
||||
|
@ -162,7 +153,7 @@ PlanetographicGrid::render(Renderer* renderer,
|
|||
glColor(Renderer::PlanetographicGridColor);
|
||||
}
|
||||
glPushMatrix();
|
||||
glTranslatef(0.0f, (float) sin(phi), 0.0f);
|
||||
glTranslatef(0.0f, (float) std::sin(phi), 0.0f);
|
||||
glScalef(r, r, r);
|
||||
glDrawArrays(GL_LINE_LOOP, 0, circleSubdivisions);
|
||||
glPopMatrix();
|
||||
|
@ -304,11 +295,11 @@ PlanetographicGrid::InitializeGeometry()
|
|||
for (unsigned int i = 0; i < circleSubdivisions; i++)
|
||||
{
|
||||
float theta = (float) (2.0 * PI) * (float) i / (float) circleSubdivisions;
|
||||
xyCircle[i * 3 + 0] = (float) cos(theta);
|
||||
xyCircle[i * 3 + 1] = (float) sin(theta);
|
||||
xyCircle[i * 3 + 0] = (float) std::cos(theta);
|
||||
xyCircle[i * 3 + 1] = (float) std::sin(theta);
|
||||
xyCircle[i * 3 + 2] = 0.0f;
|
||||
xzCircle[i * 3 + 0] = (float) cos(theta);
|
||||
xzCircle[i * 3 + 0] = (float) std::cos(theta);
|
||||
xzCircle[i * 3 + 1] = 0.0f;
|
||||
xzCircle[i * 3 + 2] = (float) sin(theta);
|
||||
xzCircle[i * 3 + 2] = (float) std::sin(theta);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
};
|
||||
|
||||
PlanetographicGrid(const Body& _body);
|
||||
~PlanetographicGrid();
|
||||
~PlanetographicGrid() = default;
|
||||
|
||||
void render(Renderer* renderer,
|
||||
const Eigen::Vector3f& pos,
|
||||
|
@ -63,11 +63,11 @@ private:
|
|||
private:
|
||||
const Body& body;
|
||||
|
||||
float minLongitudeStep;
|
||||
float minLatitudeStep;
|
||||
float minLongitudeStep{ 10.0f };
|
||||
float minLatitudeStep{ 10.0f };
|
||||
|
||||
LongitudeConvention longitudeConvention;
|
||||
NorthDirection northDirection;
|
||||
LongitudeConvention longitudeConvention{ Westward };
|
||||
NorthDirection northDirection{ NorthNormal };
|
||||
|
||||
static unsigned int circleSubdivisions;
|
||||
static float* xyCircle;
|
||||
|
|
|
@ -71,14 +71,7 @@ static ResourceHandle
|
|||
GetTextureHandle(Material::TextureResource* texResource)
|
||||
{
|
||||
CelestiaTextureResource* t = reinterpret_cast<CelestiaTextureResource*>(texResource);
|
||||
if (t)
|
||||
{
|
||||
return t->textureHandle();
|
||||
}
|
||||
else
|
||||
{
|
||||
return InvalidResource;
|
||||
}
|
||||
return t ? t->textureHandle() : InvalidResource;
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,7 +90,7 @@ RenderContext::RenderContext() :
|
|||
|
||||
RenderContext::RenderContext(const Material* _material)
|
||||
{
|
||||
if (_material == NULL)
|
||||
if (_material == nullptr)
|
||||
material = &defaultMaterial;
|
||||
else
|
||||
material = _material;
|
||||
|
@ -116,7 +109,7 @@ RenderContext::setMaterial(const Material* newMaterial)
|
|||
{
|
||||
if (!locked)
|
||||
{
|
||||
if (newMaterial == NULL)
|
||||
if (newMaterial == nullptr)
|
||||
newMaterial = &defaultMaterial;
|
||||
|
||||
if (renderPass == PrimaryPass)
|
||||
|
@ -202,19 +195,13 @@ RenderContext::drawGroup(const Mesh::PrimitiveGroup& group)
|
|||
|
||||
|
||||
FixedFunctionRenderContext::FixedFunctionRenderContext() :
|
||||
RenderContext(),
|
||||
blendMode(Material::InvalidBlend),
|
||||
specularOn(false),
|
||||
lightingEnabled(true)
|
||||
RenderContext()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FixedFunctionRenderContext::FixedFunctionRenderContext(const Material* _material) :
|
||||
RenderContext(_material),
|
||||
blendMode(Material::InvalidBlend),
|
||||
specularOn(false),
|
||||
lightingEnabled(true)
|
||||
RenderContext(_material)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -233,7 +220,7 @@ FixedFunctionRenderContext::makeCurrent(const Material& m)
|
|||
{
|
||||
if (getRenderPass() == PrimaryPass)
|
||||
{
|
||||
Texture* t = NULL;
|
||||
Texture* t = nullptr;
|
||||
|
||||
ResourceHandle diffuseMap = GetTextureHandle(getMaterial()->maps[Material::DiffuseMap]);
|
||||
|
||||
|
@ -242,7 +229,7 @@ FixedFunctionRenderContext::makeCurrent(const Material& m)
|
|||
t = GetTextureManager()->find(diffuseMap);
|
||||
}
|
||||
|
||||
if (t == NULL)
|
||||
if (t == nullptr)
|
||||
{
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
@ -255,7 +242,7 @@ FixedFunctionRenderContext::makeCurrent(const Material& m)
|
|||
Material::BlendMode newBlendMode = Material::InvalidBlend;
|
||||
if (m.opacity != 1.0f ||
|
||||
m.blend == Material::AdditiveBlend ||
|
||||
(t != NULL && t->hasAlpha()))
|
||||
(t != nullptr && t->hasAlpha()))
|
||||
{
|
||||
newBlendMode = m.blend;
|
||||
}
|
||||
|
@ -357,14 +344,14 @@ FixedFunctionRenderContext::makeCurrent(const Material& m)
|
|||
}
|
||||
else if (getRenderPass() == EmissivePass)
|
||||
{
|
||||
Texture* t = NULL;
|
||||
Texture* t = nullptr;
|
||||
ResourceHandle emissiveMap = GetTextureHandle(m.maps[Material::EmissiveMap]);
|
||||
if (emissiveMap != InvalidResource && useTexCoords)
|
||||
{
|
||||
t = GetTextureManager()->find(emissiveMap);
|
||||
}
|
||||
|
||||
if (t == NULL)
|
||||
if (t == nullptr)
|
||||
{
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
@ -393,7 +380,7 @@ FixedFunctionRenderContext::setVertexArrays(const Mesh::VertexDescription& desc,
|
|||
useNormals = useNormalsNow;
|
||||
useColors = useColorsNow;
|
||||
useTexCoords = useTexCoordsNow;
|
||||
if (getMaterial() != NULL)
|
||||
if (getMaterial() != nullptr)
|
||||
makeCurrent(*getMaterial());
|
||||
}
|
||||
|
||||
|
@ -504,7 +491,7 @@ setExtendedVertexArrays(const Mesh::VertexDescription& desc,
|
|||
const void* vertexData)
|
||||
{
|
||||
const Mesh::VertexAttribute& tangent = desc.getAttribute(Mesh::Tangent);
|
||||
const char* vertices = reinterpret_cast<const char*>(vertexData);
|
||||
const auto* vertices = reinterpret_cast<const char*>(vertexData);
|
||||
|
||||
switch (tangent.format)
|
||||
{
|
||||
|
@ -545,12 +532,9 @@ setExtendedVertexArrays(const Mesh::VertexDescription& desc,
|
|||
|
||||
GLSL_RenderContext::GLSL_RenderContext(const LightingState& ls, float _objRadius, const Quaternionf& orientation) :
|
||||
lightingState(ls),
|
||||
atmosphere(NULL),
|
||||
blendMode(Material::InvalidBlend),
|
||||
objRadius(_objRadius),
|
||||
objScale(Vector3f::Constant(_objRadius)),
|
||||
objOrientation(orientation),
|
||||
lunarLambert(0.0f)
|
||||
objOrientation(orientation)
|
||||
{
|
||||
initLightingEnvironment();
|
||||
}
|
||||
|
@ -558,12 +542,9 @@ GLSL_RenderContext::GLSL_RenderContext(const LightingState& ls, float _objRadius
|
|||
|
||||
GLSL_RenderContext::GLSL_RenderContext(const LightingState& ls, const Eigen::Vector3f& _objScale, const Quaternionf& orientation) :
|
||||
lightingState(ls),
|
||||
atmosphere(NULL),
|
||||
blendMode(Material::InvalidBlend),
|
||||
objRadius(_objScale.maxCoeff()),
|
||||
objScale(_objScale),
|
||||
objOrientation(orientation),
|
||||
lunarLambert(0.0f)
|
||||
objOrientation(orientation)
|
||||
{
|
||||
initLightingEnvironment();
|
||||
}
|
||||
|
@ -606,14 +587,14 @@ GLSL_RenderContext::initLightingEnvironment()
|
|||
void
|
||||
GLSL_RenderContext::makeCurrent(const Material& m)
|
||||
{
|
||||
Texture* textures[4] = { NULL, NULL, NULL, NULL };
|
||||
Texture* textures[4] = { nullptr, nullptr, nullptr, nullptr };
|
||||
unsigned int nTextures = 0;
|
||||
|
||||
// Set up the textures used by this object
|
||||
Texture* baseTex = NULL;
|
||||
Texture* bumpTex = NULL;
|
||||
Texture* specTex = NULL;
|
||||
Texture* emissiveTex = NULL;
|
||||
Texture* baseTex = nullptr;
|
||||
Texture* bumpTex = nullptr;
|
||||
Texture* specTex = nullptr;
|
||||
Texture* emissiveTex = nullptr;
|
||||
|
||||
shaderProps.texUsage = ShaderProperties::SharedTextureCoords;
|
||||
|
||||
|
@ -645,7 +626,7 @@ GLSL_RenderContext::makeCurrent(const Material& m)
|
|||
if (diffuseMap != InvalidResource && (useTexCoords || usePointSize))
|
||||
{
|
||||
baseTex = GetTextureManager()->find(diffuseMap);
|
||||
if (baseTex != NULL)
|
||||
if (baseTex != nullptr)
|
||||
{
|
||||
shaderProps.texUsage |= ShaderProperties::DiffuseTexture;
|
||||
textures[nTextures++] = baseTex;
|
||||
|
@ -655,7 +636,7 @@ GLSL_RenderContext::makeCurrent(const Material& m)
|
|||
if (normalMap != InvalidResource)
|
||||
{
|
||||
bumpTex = GetTextureManager()->find(normalMap);
|
||||
if (bumpTex != NULL)
|
||||
if (bumpTex != nullptr)
|
||||
{
|
||||
shaderProps.texUsage |= ShaderProperties::NormalTexture;
|
||||
if (bumpTex->getFormatOptions() & Texture::DXT5NormalMap)
|
||||
|
@ -670,9 +651,9 @@ GLSL_RenderContext::makeCurrent(const Material& m)
|
|||
{
|
||||
shaderProps.lightModel = ShaderProperties::PerPixelSpecularModel;
|
||||
specTex = GetTextureManager()->find(specularMap);
|
||||
if (specTex == NULL)
|
||||
if (specTex == nullptr)
|
||||
{
|
||||
if (baseTex != NULL)
|
||||
if (baseTex != nullptr)
|
||||
shaderProps.texUsage |= ShaderProperties::SpecularInDiffuseAlpha;
|
||||
}
|
||||
else
|
||||
|
@ -685,7 +666,7 @@ GLSL_RenderContext::makeCurrent(const Material& m)
|
|||
if (emissiveMap != InvalidResource)
|
||||
{
|
||||
emissiveTex = GetTextureManager()->find(emissiveMap);
|
||||
if (emissiveTex != NULL)
|
||||
if (emissiveTex != nullptr)
|
||||
{
|
||||
shaderProps.texUsage |= ShaderProperties::EmissiveTexture;
|
||||
textures[nTextures++] = emissiveTex;
|
||||
|
@ -695,7 +676,7 @@ GLSL_RenderContext::makeCurrent(const Material& m)
|
|||
if (lightingState.shadowingRingSystem)
|
||||
{
|
||||
Texture* ringsTex = lightingState.shadowingRingSystem->texture.find(medres);
|
||||
if (ringsTex != NULL)
|
||||
if (ringsTex != nullptr)
|
||||
{
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + nTextures);
|
||||
ringsTex->bind();
|
||||
|
@ -729,7 +710,7 @@ GLSL_RenderContext::makeCurrent(const Material& m)
|
|||
if (useColors)
|
||||
shaderProps.texUsage |= ShaderProperties::VertexColors;
|
||||
|
||||
if (atmosphere != NULL)
|
||||
if (atmosphere != nullptr)
|
||||
{
|
||||
// Only use new atmosphere code in OpenGL 2.0 path when new style parameters are defined.
|
||||
if (atmosphere->mieScaleHeight > 0.0f)
|
||||
|
@ -738,7 +719,7 @@ GLSL_RenderContext::makeCurrent(const Material& m)
|
|||
|
||||
// Get a shader for the current rendering configuration
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shaderProps);
|
||||
if (prog == NULL)
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
prog->use();
|
||||
|
@ -779,7 +760,7 @@ GLSL_RenderContext::makeCurrent(const Material& m)
|
|||
// a planet mesh. See SourceForge bug #1855894 for more details.
|
||||
bool disableDepthWriteOnBlend = true;
|
||||
|
||||
if (atmosphere != NULL && shaderProps.hasScattering())
|
||||
if (atmosphere != nullptr && shaderProps.hasScattering())
|
||||
{
|
||||
prog->setAtmosphereParameters(*atmosphere, objRadius, objRadius);
|
||||
disableDepthWriteOnBlend = false;
|
||||
|
@ -812,7 +793,7 @@ GLSL_RenderContext::makeCurrent(const Material& m)
|
|||
Material::BlendMode newBlendMode = Material::InvalidBlend;
|
||||
if (m.opacity != 1.0f ||
|
||||
m.blend == Material::AdditiveBlend ||
|
||||
(baseTex != NULL && baseTex->hasAlpha()))
|
||||
(baseTex != nullptr && baseTex->hasAlpha()))
|
||||
{
|
||||
newBlendMode = m.blend;
|
||||
}
|
||||
|
@ -871,7 +852,7 @@ GLSL_RenderContext::setVertexArrays(const Mesh::VertexDescription& desc,
|
|||
useNormals = useNormalsNow;
|
||||
useColors = useColorsNow;
|
||||
useTexCoords = useTexCoordsNow;
|
||||
if (getMaterial() != NULL)
|
||||
if (getMaterial() != nullptr)
|
||||
makeCurrent(*getMaterial());
|
||||
}
|
||||
}
|
||||
|
@ -924,11 +905,11 @@ GLSLUnlit_RenderContext::initLightingEnvironment()
|
|||
void
|
||||
GLSLUnlit_RenderContext::makeCurrent(const Material& m)
|
||||
{
|
||||
Texture* textures[4] = { NULL, NULL, NULL, NULL };
|
||||
Texture* textures[4] = { nullptr, nullptr, nullptr, nullptr };
|
||||
unsigned int nTextures = 0;
|
||||
|
||||
// Set up the textures used by this object
|
||||
Texture* baseTex = NULL;
|
||||
Texture* baseTex = nullptr;
|
||||
|
||||
shaderProps.lightModel = ShaderProperties::EmissiveModel;
|
||||
shaderProps.texUsage = ShaderProperties::SharedTextureCoords;
|
||||
|
@ -937,7 +918,7 @@ GLSLUnlit_RenderContext::makeCurrent(const Material& m)
|
|||
if (diffuseMap != InvalidResource && (useTexCoords || usePointSize))
|
||||
{
|
||||
baseTex = GetTextureManager()->find(diffuseMap);
|
||||
if (baseTex != NULL)
|
||||
if (baseTex != nullptr)
|
||||
{
|
||||
shaderProps.texUsage |= ShaderProperties::DiffuseTexture;
|
||||
textures[nTextures++] = baseTex;
|
||||
|
@ -951,7 +932,7 @@ GLSLUnlit_RenderContext::makeCurrent(const Material& m)
|
|||
|
||||
// Get a shader for the current rendering configuration
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shaderProps);
|
||||
if (prog == NULL)
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
prog->use();
|
||||
|
@ -978,7 +959,7 @@ GLSLUnlit_RenderContext::makeCurrent(const Material& m)
|
|||
Material::BlendMode newBlendMode = Material::InvalidBlend;
|
||||
if (m.opacity != 1.0f ||
|
||||
m.blend == Material::AdditiveBlend ||
|
||||
(baseTex != NULL && baseTex->hasAlpha()))
|
||||
(baseTex != nullptr && baseTex->hasAlpha()))
|
||||
{
|
||||
newBlendMode = m.blend;
|
||||
}
|
||||
|
@ -1037,7 +1018,7 @@ GLSLUnlit_RenderContext::setVertexArrays(const Mesh::VertexDescription& desc,
|
|||
useNormals = useNormalsNow;
|
||||
useColors = useColorsNow;
|
||||
useTexCoords = useTexCoordsNow;
|
||||
if (getMaterial() != NULL)
|
||||
if (getMaterial() != nullptr)
|
||||
makeCurrent(*getMaterial());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class RenderContext
|
|||
|
||||
RenderContext(const cmod::Material*);
|
||||
RenderContext();
|
||||
virtual ~RenderContext() {};
|
||||
virtual ~RenderContext() = default;
|
||||
|
||||
virtual void makeCurrent(const cmod::Material&) = 0;
|
||||
virtual void setVertexArrays(const cmod::Mesh::VertexDescription& desc,
|
||||
|
@ -79,9 +79,9 @@ class FixedFunctionRenderContext : public RenderContext
|
|||
void setLighting(bool);
|
||||
|
||||
private:
|
||||
cmod::Material::BlendMode blendMode;
|
||||
bool specularOn;
|
||||
bool lightingEnabled;
|
||||
cmod::Material::BlendMode blendMode{ cmod::Material::InvalidBlend };
|
||||
bool specularOn{ false };
|
||||
bool lightingEnabled{ true };
|
||||
};
|
||||
|
||||
|
||||
|
@ -132,14 +132,14 @@ class GLSL_RenderContext : public RenderContext
|
|||
|
||||
private:
|
||||
const LightingState& lightingState;
|
||||
const Atmosphere* atmosphere;
|
||||
cmod::Material::BlendMode blendMode;
|
||||
const Atmosphere* atmosphere{ nullptr };
|
||||
cmod::Material::BlendMode blendMode{ cmod::Material::InvalidBlend };
|
||||
float objRadius;
|
||||
Eigen::Vector3f objScale;
|
||||
Eigen::Quaternionf objOrientation;
|
||||
|
||||
// extended material properties
|
||||
float lunarLambert;
|
||||
float lunarLambert{ 0.0f };
|
||||
|
||||
ShaderProperties shaderProps;
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -108,7 +108,7 @@ class Renderer
|
|||
void shutdown() {};
|
||||
void resize(int, int);
|
||||
|
||||
float calcPixelSize(float fov, float windowHeight);
|
||||
float calcPixelSize(float fovY, float windowHeight);
|
||||
void setFaintestAM45deg(float);
|
||||
float getFaintestAM45deg() const;
|
||||
|
||||
|
@ -352,9 +352,9 @@ class Renderer
|
|||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||
|
||||
RenderProperties() :
|
||||
surface(NULL),
|
||||
atmosphere(NULL),
|
||||
rings(NULL),
|
||||
surface(nullptr),
|
||||
atmosphere(nullptr),
|
||||
rings(nullptr),
|
||||
radius(1.0f),
|
||||
geometryScale(1.0f),
|
||||
semiAxes(1.0f, 1.0f, 1.0f),
|
||||
|
@ -395,7 +395,7 @@ class Renderer
|
|||
std::string label;
|
||||
|
||||
ObjectLabel() :
|
||||
obj (NULL),
|
||||
obj (nullptr),
|
||||
label("")
|
||||
{};
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
float radius = semiAxes.maxCoeff();
|
||||
|
||||
Texture* textures[MAX_SPHERE_MESH_TEXTURES] =
|
||||
{ NULL, NULL, NULL, NULL, NULL, NULL };
|
||||
{ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
|
||||
unsigned int nTextures = 0;
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
@ -75,13 +75,13 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
shadprop.nLights = min(ls.nLights, MaxShaderLights);
|
||||
|
||||
// Set up the textures used by this object
|
||||
if (ri.baseTex != NULL)
|
||||
if (ri.baseTex != nullptr)
|
||||
{
|
||||
shadprop.texUsage = ShaderProperties::DiffuseTexture;
|
||||
textures[nTextures++] = ri.baseTex;
|
||||
}
|
||||
|
||||
if (ri.bumpTex != NULL)
|
||||
if (ri.bumpTex != nullptr)
|
||||
{
|
||||
shadprop.texUsage |= ShaderProperties::NormalTexture;
|
||||
textures[nTextures++] = ri.bumpTex;
|
||||
|
@ -92,7 +92,7 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
if (ri.specularColor != Color::Black)
|
||||
{
|
||||
shadprop.lightModel = ShaderProperties::PerPixelSpecularModel;
|
||||
if (ri.glossTex == NULL)
|
||||
if (ri.glossTex == nullptr)
|
||||
{
|
||||
shadprop.texUsage |= ShaderProperties::SpecularInDiffuseAlpha;
|
||||
}
|
||||
|
@ -108,21 +108,21 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
shadprop.lightModel = ShaderProperties::LunarLambertModel;
|
||||
}
|
||||
|
||||
if (ri.nightTex != NULL)
|
||||
if (ri.nightTex != nullptr)
|
||||
{
|
||||
shadprop.texUsage |= ShaderProperties::NightTexture;
|
||||
textures[nTextures++] = ri.nightTex;
|
||||
}
|
||||
|
||||
if (ri.overlayTex != NULL)
|
||||
if (ri.overlayTex != nullptr)
|
||||
{
|
||||
shadprop.texUsage |= ShaderProperties::OverlayTexture;
|
||||
textures[nTextures++] = ri.overlayTex;
|
||||
}
|
||||
|
||||
if (atmosphere != NULL)
|
||||
if (atmosphere != nullptr)
|
||||
{
|
||||
if (renderFlags & Renderer::ShowAtmospheres)
|
||||
if ((renderFlags & Renderer::ShowAtmospheres) != 0)
|
||||
{
|
||||
// Only use new atmosphere code in OpenGL 2.0 path when new style parameters are defined.
|
||||
// ... but don't show atmospheres when there are no light sources.
|
||||
|
@ -133,7 +133,7 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
if ((renderFlags & Renderer::ShowCloudMaps) != 0 &&
|
||||
(renderFlags & Renderer::ShowCloudShadows) != 0)
|
||||
{
|
||||
Texture* cloudTex = NULL;
|
||||
Texture* cloudTex = nullptr;
|
||||
if (atmosphere->cloudTexture.tex[textureRes] != InvalidResource)
|
||||
cloudTex = atmosphere->cloudTexture.find(textureRes);
|
||||
|
||||
|
@ -142,7 +142,7 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
bool allowCloudShadows = true;
|
||||
for (unsigned int i = 0; i < nTextures; i++)
|
||||
{
|
||||
if (textures[i] != NULL &&
|
||||
if (textures[i] != nullptr &&
|
||||
(textures[i]->getLODCount() > 1 ||
|
||||
textures[i]->getUTileCount(0) > 1 ||
|
||||
textures[i]->getVTileCount(0) > 1))
|
||||
|
@ -152,7 +152,7 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
}
|
||||
|
||||
// Split cloud shadows can't cast shadows
|
||||
if (cloudTex != NULL)
|
||||
if (cloudTex != nullptr)
|
||||
{
|
||||
if (cloudTex->getLODCount() > 1 ||
|
||||
cloudTex->getUTileCount(0) > 1 ||
|
||||
|
@ -162,7 +162,7 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
}
|
||||
}
|
||||
|
||||
if (cloudTex != NULL && allowCloudShadows && atmosphere->cloudShadowDepth > 0.0f)
|
||||
if (cloudTex != nullptr && allowCloudShadows && atmosphere->cloudShadowDepth > 0.0f)
|
||||
{
|
||||
shadprop.texUsage |= ShaderProperties::CloudShadowTexture;
|
||||
textures[nTextures++] = cloudTex;
|
||||
|
@ -200,7 +200,7 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
if (ls.shadowingRingSystem)
|
||||
{
|
||||
Texture* ringsTex = ls.shadowingRingSystem->texture.find(textureRes);
|
||||
if (ringsTex != NULL)
|
||||
if (ringsTex != nullptr)
|
||||
{
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + nTextures);
|
||||
ringsTex->bind();
|
||||
|
@ -229,7 +229,7 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
|
||||
// Get a shader for the current rendering configuration
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shadprop);
|
||||
if (prog == NULL)
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
prog->use();
|
||||
|
@ -245,7 +245,7 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
if (shadprop.lightModel == ShaderProperties::LunarLambertModel)
|
||||
prog->lunarLambert = ri.lunarLambert;
|
||||
|
||||
if (shadprop.texUsage & ShaderProperties::RingShadowTexture)
|
||||
if ((shadprop.texUsage & ShaderProperties::RingShadowTexture) != 0)
|
||||
{
|
||||
float ringWidth = ls.shadowingRingSystem->outerRadius - ls.shadowingRingSystem->innerRadius;
|
||||
prog->ringRadius = ls.shadowingRingSystem->innerRadius / radius;
|
||||
|
@ -261,9 +261,9 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
}
|
||||
}
|
||||
|
||||
if (atmosphere != NULL)
|
||||
if (atmosphere != nullptr)
|
||||
{
|
||||
if (shadprop.texUsage & ShaderProperties::CloudShadowTexture)
|
||||
if ((shadprop.texUsage & ShaderProperties::CloudShadowTexture) != 0)
|
||||
{
|
||||
prog->shadowTextureOffset = cloudTexOffset;
|
||||
prog->cloudHeight = 1.0f + atmosphere->cloudHeight / radius;
|
||||
|
@ -281,7 +281,7 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
glColor(ri.color);
|
||||
|
||||
unsigned int attributes = LODSphereMesh::Normals;
|
||||
if (ri.bumpTex != NULL)
|
||||
if (ri.bumpTex != nullptr)
|
||||
attributes |= LODSphereMesh::Tangents;
|
||||
g_lodSphere->render(context,
|
||||
attributes,
|
||||
|
@ -310,7 +310,7 @@ void renderGeometry_GLSL(Geometry* geometry,
|
|||
|
||||
GLSL_RenderContext rc(ls, geometryScale, planetOrientation);
|
||||
|
||||
if (renderFlags & Renderer::ShowAtmospheres)
|
||||
if ((renderFlags & Renderer::ShowAtmospheres) != 0)
|
||||
{
|
||||
rc.setAtmosphere(atmosphere);
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ void renderGeometry_GLSL(Geometry* geometry,
|
|||
rc.setMaterial(&m);
|
||||
rc.lock();
|
||||
geometry->render(rc, tsec);
|
||||
m.maps[Material::DiffuseMap] = NULL; // prevent Material destructor from deleting the texture resource
|
||||
m.maps[Material::DiffuseMap] = nullptr; // prevent Material destructor from deleting the texture resource
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -378,7 +378,7 @@ void renderGeometry_GLSL_Unlit(Geometry* geometry,
|
|||
rc.setMaterial(&m);
|
||||
rc.lock();
|
||||
geometry->render(rc, tsec);
|
||||
m.maps[Material::DiffuseMap] = NULL; // prevent Material destructor from deleting the texture resource
|
||||
m.maps[Material::DiffuseMap] = nullptr; // prevent Material destructor from deleting the texture resource
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -406,7 +406,7 @@ void renderClouds_GLSL(const RenderInfo& ri,
|
|||
float radius = semiAxes.maxCoeff();
|
||||
|
||||
Texture* textures[MAX_SPHERE_MESH_TEXTURES] =
|
||||
{ NULL, NULL, NULL, NULL, NULL, NULL };
|
||||
{ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
|
||||
unsigned int nTextures = 0;
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
@ -415,13 +415,13 @@ void renderClouds_GLSL(const RenderInfo& ri,
|
|||
shadprop.nLights = ls.nLights;
|
||||
|
||||
// Set up the textures used by this object
|
||||
if (cloudTex != NULL)
|
||||
if (cloudTex != nullptr)
|
||||
{
|
||||
shadprop.texUsage = ShaderProperties::DiffuseTexture;
|
||||
textures[nTextures++] = cloudTex;
|
||||
}
|
||||
|
||||
if (cloudNormalMap != NULL)
|
||||
if (cloudNormalMap != nullptr)
|
||||
{
|
||||
shadprop.texUsage |= ShaderProperties::NormalTexture;
|
||||
textures[nTextures++] = cloudNormalMap;
|
||||
|
@ -430,10 +430,10 @@ void renderClouds_GLSL(const RenderInfo& ri,
|
|||
}
|
||||
|
||||
#if 0
|
||||
if (rings != NULL && (renderFlags & Renderer::ShowRingShadows) != 0)
|
||||
if (rings != nullptr && (renderFlags & Renderer::ShowRingShadows) != 0)
|
||||
{
|
||||
Texture* ringsTex = rings->texture.find(textureRes);
|
||||
if (ringsTex != NULL)
|
||||
if (ringsTex != nullptr)
|
||||
{
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + nTextures);
|
||||
ringsTex->bind();
|
||||
|
@ -452,9 +452,9 @@ void renderClouds_GLSL(const RenderInfo& ri,
|
|||
}
|
||||
#endif
|
||||
|
||||
if (atmosphere != NULL)
|
||||
if (atmosphere != nullptr)
|
||||
{
|
||||
if (renderFlags & Renderer::ShowAtmospheres)
|
||||
if ((renderFlags & Renderer::ShowAtmospheres) != 0)
|
||||
{
|
||||
// Only use new atmosphere code in OpenGL 2.0 path when new style parameters are defined.
|
||||
// ... but don't show atmospheres when there are no light sources.
|
||||
|
@ -479,7 +479,7 @@ void renderClouds_GLSL(const RenderInfo& ri,
|
|||
|
||||
// Get a shader for the current rendering configuration
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shadprop);
|
||||
if (prog == NULL)
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
prog->use();
|
||||
|
@ -490,7 +490,7 @@ void renderClouds_GLSL(const RenderInfo& ri,
|
|||
ri.ambientColor.blue());
|
||||
prog->textureOffset = texOffset;
|
||||
|
||||
if (atmosphere != NULL)
|
||||
if (atmosphere != nullptr)
|
||||
{
|
||||
float cloudRadius = radius + atmosphere->cloudHeight;
|
||||
|
||||
|
@ -513,7 +513,7 @@ void renderClouds_GLSL(const RenderInfo& ri,
|
|||
prog->setEclipseShadowParameters(ls, semiAxes, planetOrientation);
|
||||
|
||||
unsigned int attributes = LODSphereMesh::Normals;
|
||||
if (cloudNormalMap != NULL)
|
||||
if (cloudNormalMap != nullptr)
|
||||
attributes |= LODSphereMesh::Tangents;
|
||||
g_lodSphere->render(context,
|
||||
attributes,
|
||||
|
@ -552,7 +552,7 @@ renderAtmosphere_GLSL(const RenderInfo& ri,
|
|||
|
||||
// Get a shader for the current rendering configuration
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shadprop);
|
||||
if (prog == NULL)
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
prog->use();
|
||||
|
@ -583,7 +583,7 @@ renderAtmosphere_GLSL(const RenderInfo& ri,
|
|||
LODSphereMesh::Normals,
|
||||
frustum,
|
||||
ri.pixWidth,
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
@ -611,8 +611,8 @@ static void renderRingSystem(float innerRadius,
|
|||
{
|
||||
float t = (float) i / (float) nSections;
|
||||
float theta = beginAngle + t * angle;
|
||||
float s = (float) sin(theta);
|
||||
float c = (float) cos(theta);
|
||||
auto s = (float) sin(theta);
|
||||
auto c = (float) cos(theta);
|
||||
glTexCoord2f(0, 0.5f);
|
||||
glVertex3f(c * innerRadius, 0, s * innerRadius);
|
||||
glTexCoord2f(1, 0.5f);
|
||||
|
@ -649,14 +649,14 @@ void renderRings_GLSL(RingSystem& rings,
|
|||
shadprop.setEclipseShadowCountForLight(li, 1);
|
||||
}
|
||||
|
||||
if (ringsTex)
|
||||
if (ringsTex != nullptr)
|
||||
shadprop.texUsage = ShaderProperties::DiffuseTexture;
|
||||
}
|
||||
|
||||
|
||||
// Get a shader for the current rendering configuration
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shadprop);
|
||||
if (prog == NULL)
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
prog->use();
|
||||
|
@ -730,7 +730,7 @@ void renderRings_GLSL(RingSystem& rings,
|
|||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
if (ringsTex != NULL)
|
||||
if (ringsTex != nullptr)
|
||||
ringsTex->bind();
|
||||
else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
@ -853,7 +853,7 @@ FramebufferObject::generateColorTexture()
|
|||
|
||||
// Set the texture dimensions
|
||||
// Do we need to set GL_DEPTH_COMPONENT24 here?
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, m_width, m_height, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, m_width, m_height, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
|
||||
|
||||
// Unbind the texture
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
@ -877,7 +877,7 @@ FramebufferObject::generateDepthTexture()
|
|||
|
||||
// Set the texture dimensions
|
||||
// Do we need to set GL_DEPTH_COMPONENT24 here?
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, m_width, m_height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, m_width, m_height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, nullptr);
|
||||
|
||||
// Unbind the texture
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
@ -962,10 +962,8 @@ FramebufferObject::bind()
|
|||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fboId);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,11 +41,11 @@ struct RenderInfo
|
|||
#else
|
||||
color(1.0f, 1.0f, 1.0f),
|
||||
#endif
|
||||
baseTex(NULL),
|
||||
bumpTex(NULL),
|
||||
nightTex(NULL),
|
||||
glossTex(NULL),
|
||||
overlayTex(NULL),
|
||||
baseTex(nullptr),
|
||||
bumpTex(nullptr),
|
||||
nightTex(nullptr),
|
||||
glossTex(nullptr),
|
||||
overlayTex(nullptr),
|
||||
hazeColor(0.0f, 0.0f, 0.0f),
|
||||
specularColor(0.0f, 0.0f, 0.0f),
|
||||
specularPower(0.0f),
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
using namespace std;
|
||||
|
||||
|
||||
static RotationModelManager* rotationModelManager = NULL;
|
||||
static RotationModelManager* rotationModelManager = nullptr;
|
||||
|
||||
|
||||
RotationModelManager* GetRotationModelManager()
|
||||
{
|
||||
if (rotationModelManager == NULL)
|
||||
if (rotationModelManager == nullptr)
|
||||
rotationModelManager = new RotationModelManager("data");
|
||||
return rotationModelManager;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ string RotationModelInfo::resolve(const string& baseDir)
|
|||
if (!path.empty())
|
||||
{
|
||||
string filename = path + "/data/" + source;
|
||||
ifstream in(filename.c_str());
|
||||
ifstream in(filename);
|
||||
if (in.good())
|
||||
return filename;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ UniversalCoord Selection::getPosition(double t) const
|
|||
case Type_Location:
|
||||
{
|
||||
Body* body = location()->getParentBody();
|
||||
if (body != NULL)
|
||||
if (body != nullptr)
|
||||
{
|
||||
return body->getPosition(t).offsetKm(location()->getPlanetocentricPosition(t));
|
||||
}
|
||||
|
@ -128,10 +128,10 @@ string Selection::getName(bool i18n) const
|
|||
{
|
||||
string name = body()->getName(i18n);
|
||||
PlanetarySystem* system = body()->getSystem();
|
||||
while (system != NULL)
|
||||
while (system != nullptr)
|
||||
{
|
||||
Body* parent = system->getPrimaryBody();
|
||||
if (parent != NULL)
|
||||
if (parent != nullptr)
|
||||
{
|
||||
name = parent->getName(i18n) + '/' + name;
|
||||
system = parent->getSystem();
|
||||
|
@ -139,20 +139,20 @@ string Selection::getName(bool i18n) const
|
|||
else
|
||||
{
|
||||
const Star* parentStar = system->getStar();
|
||||
if (parentStar != NULL)
|
||||
if (parentStar != nullptr)
|
||||
{
|
||||
char buf[20];
|
||||
sprintf(buf, "#%d", parentStar->getCatalogNumber());
|
||||
name = string(buf) + '/' + name;
|
||||
}
|
||||
system = NULL;
|
||||
system = nullptr;
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
case Type_Location:
|
||||
if (location()->getParentBody() == NULL)
|
||||
if (location()->getParentBody() == nullptr)
|
||||
{
|
||||
return location()->getName(i18n);
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ Selection Selection::parent() const
|
|||
case Type_Body:
|
||||
if (body()->getSystem())
|
||||
{
|
||||
if (body()->getSystem()->getPrimaryBody() != NULL)
|
||||
if (body()->getSystem()->getPrimaryBody() != nullptr)
|
||||
return Selection(body()->getSystem()->getPrimaryBody());
|
||||
else
|
||||
return Selection(body()->getSystem()->getStar());
|
||||
|
|
|
@ -30,7 +30,7 @@ class Selection
|
|||
};
|
||||
|
||||
public:
|
||||
Selection() : type(Type_Nil), obj(NULL) {};
|
||||
Selection() : type(Type_Nil), obj(nullptr) {};
|
||||
Selection(Star* star) : type(Type_Star), obj(star) { checkNull(); };
|
||||
Selection(Body* body) : type(Type_Body), obj(body) { checkNull(); };
|
||||
Selection(DeepSkyObject* deepsky) : type(Type_DeepSky), obj(deepsky) {checkNull(); };
|
||||
|
@ -49,22 +49,22 @@ class Selection
|
|||
|
||||
Star* star() const
|
||||
{
|
||||
return type == Type_Star ? static_cast<Star*>(obj) : NULL;
|
||||
return type == Type_Star ? static_cast<Star*>(obj) : nullptr;
|
||||
}
|
||||
|
||||
Body* body() const
|
||||
{
|
||||
return type == Type_Body ? static_cast<Body*>(obj) : NULL;
|
||||
return type == Type_Body ? static_cast<Body*>(obj) : nullptr;
|
||||
}
|
||||
|
||||
DeepSkyObject* deepsky() const
|
||||
{
|
||||
return type == Type_DeepSky ? static_cast<DeepSkyObject*>(obj) : NULL;
|
||||
return type == Type_DeepSky ? static_cast<DeepSkyObject*>(obj) : nullptr;
|
||||
}
|
||||
|
||||
Location* location() const
|
||||
{
|
||||
return type == Type_Location ? static_cast<Location*>(obj) : NULL;
|
||||
return type == Type_Location ? static_cast<Location*>(obj) : nullptr;
|
||||
}
|
||||
|
||||
Type getType() const { return type; }
|
||||
|
@ -73,7 +73,7 @@ class Selection
|
|||
Type type;
|
||||
void* obj;
|
||||
|
||||
void checkNull() { if (obj == NULL) type = Type_Nil; }
|
||||
void checkNull() { if (obj == nullptr) type = Type_Nil; }
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -82,10 +82,7 @@ ShaderProperties::usesShadows() const
|
|||
bool
|
||||
ShaderProperties::usesFragmentLighting() const
|
||||
{
|
||||
if ((texUsage & NormalTexture) != 0 || lightModel == PerPixelSpecularModel)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return (texUsage & NormalTexture) != 0 || lightModel == PerPixelSpecularModel;
|
||||
}
|
||||
|
||||
|
||||
|
@ -265,22 +262,22 @@ bool operator<(const ShaderProperties& p0, const ShaderProperties& p1)
|
|||
{
|
||||
if (p0.texUsage < p1.texUsage)
|
||||
return true;
|
||||
else if (p1.texUsage < p0.texUsage)
|
||||
if (p1.texUsage < p0.texUsage)
|
||||
return false;
|
||||
|
||||
if (p0.nLights < p1.nLights)
|
||||
return true;
|
||||
else if (p1.nLights < p0.nLights)
|
||||
if (p1.nLights < p0.nLights)
|
||||
return false;
|
||||
|
||||
if (p0.shadowCounts < p1.shadowCounts)
|
||||
return true;
|
||||
else if (p1.shadowCounts < p0.shadowCounts)
|
||||
if (p1.shadowCounts < p0.shadowCounts)
|
||||
return false;
|
||||
|
||||
if (p0.effects < p1.effects)
|
||||
return true;
|
||||
else if (p1.effects < p0.effects)
|
||||
if (p1.effects < p0.effects)
|
||||
return false;
|
||||
|
||||
return (p0.lightModel < p1.lightModel);
|
||||
|
@ -292,7 +289,7 @@ ShaderManager::ShaderManager()
|
|||
#if defined(_DEBUG) || defined(DEBUG) || 1
|
||||
// Only write to shader log file if this is a debug build
|
||||
|
||||
if (g_shaderLogFile == NULL)
|
||||
if (g_shaderLogFile == nullptr)
|
||||
#ifdef _WIN32
|
||||
g_shaderLogFile = new ofstream("shaders.log");
|
||||
#else
|
||||
|
@ -303,11 +300,6 @@ ShaderManager::ShaderManager()
|
|||
}
|
||||
|
||||
|
||||
ShaderManager::~ShaderManager()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CelestiaGLProgram*
|
||||
ShaderManager::getShader(const ShaderProperties& props)
|
||||
{
|
||||
|
@ -410,8 +402,8 @@ IndexedParameter(const char* name, unsigned int index0, unsigned int index1)
|
|||
class Sh_ExpressionContents
|
||||
{
|
||||
protected:
|
||||
Sh_ExpressionContents() : m_refCount(0) {}
|
||||
virtual ~Sh_ExpressionContents() {};
|
||||
Sh_ExpressionContents() {}
|
||||
virtual ~Sh_ExpressionContents() = default;;
|
||||
|
||||
public:
|
||||
virtual string toString() const = 0;
|
||||
|
@ -438,7 +430,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
mutable int m_refCount;
|
||||
mutable int m_refCount{0};
|
||||
};
|
||||
|
||||
|
||||
|
@ -446,14 +438,14 @@ class Sh_ConstantExpression : public Sh_ExpressionContents
|
|||
{
|
||||
public:
|
||||
Sh_ConstantExpression(float value) : m_value(value) {}
|
||||
virtual string toString() const
|
||||
string toString() const override
|
||||
{
|
||||
char buf[32];
|
||||
sprintf(buf, "%f", m_value);
|
||||
return string(buf);
|
||||
}
|
||||
|
||||
virtual int precedence() const { return 100; }
|
||||
int precedence() const override { return 100; }
|
||||
|
||||
private:
|
||||
float m_value;
|
||||
|
@ -525,12 +517,12 @@ class Sh_VariableExpression : public Sh_ExpressionContents
|
|||
{
|
||||
public:
|
||||
Sh_VariableExpression(const string& name) : m_name(name) {}
|
||||
virtual string toString() const
|
||||
string toString() const override
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
virtual int precedence() const { return 100; }
|
||||
int precedence() const override { return 100; }
|
||||
|
||||
private:
|
||||
const string m_name;
|
||||
|
@ -545,12 +537,12 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
virtual string toString() const
|
||||
string toString() const override
|
||||
{
|
||||
return m_expr.toStringPrecedence(precedence()) + "." + m_components;
|
||||
}
|
||||
|
||||
int precedence() const { return 99; }
|
||||
int precedence() const override { return 99; }
|
||||
|
||||
private:
|
||||
const Sh_Expression m_expr;
|
||||
|
@ -566,7 +558,7 @@ public:
|
|||
m_left(left),
|
||||
m_right(right) {};
|
||||
|
||||
virtual string toString() const
|
||||
string toString() const override
|
||||
{
|
||||
return left().toStringPrecedence(precedence()) + op() + right().toStringPrecedence(precedence());
|
||||
}
|
||||
|
@ -574,7 +566,7 @@ public:
|
|||
const Sh_Expression& left() const { return m_left; }
|
||||
const Sh_Expression& right() const { return m_right; }
|
||||
string op() const { return m_op; }
|
||||
int precedence() const { return m_precedence; }
|
||||
int precedence() const override { return m_precedence; }
|
||||
|
||||
private:
|
||||
string m_op;
|
||||
|
@ -642,12 +634,12 @@ public:
|
|||
Sh_UnaryFunctionExpression(const string& name, const Sh_Expression& arg0) :
|
||||
m_name(name), m_arg0(arg0) {}
|
||||
|
||||
virtual string toString() const
|
||||
string toString() const override
|
||||
{
|
||||
return m_name + "(" + m_arg0.toString() + ")";
|
||||
}
|
||||
|
||||
virtual int precedence() const { return 100; }
|
||||
int precedence() const override { return 100; }
|
||||
|
||||
private:
|
||||
string m_name;
|
||||
|
@ -660,12 +652,12 @@ public:
|
|||
Sh_BinaryFunctionExpression(const string& name, const Sh_Expression& arg0, const Sh_Expression& arg1) :
|
||||
m_name(name), m_arg0(arg0), m_arg1(arg1) {}
|
||||
|
||||
virtual string toString() const
|
||||
string toString() const override
|
||||
{
|
||||
return m_name + "(" + m_arg0.toString() + ", " + m_arg1.toString() + ")";
|
||||
}
|
||||
|
||||
virtual int precedence() const { return 100; }
|
||||
int precedence() const override { return 100; }
|
||||
|
||||
private:
|
||||
string m_name;
|
||||
|
@ -679,12 +671,12 @@ public:
|
|||
Sh_TernaryFunctionExpression(const string& name, const Sh_Expression& arg0, const Sh_Expression& arg1, const Sh_Expression& arg2) :
|
||||
m_name(name), m_arg0(arg0), m_arg1(arg1), m_arg2(arg2) {}
|
||||
|
||||
virtual string toString() const
|
||||
string toString() const override
|
||||
{
|
||||
return m_name + "(" + m_arg0.toString() + ", " + m_arg1.toString() + ", " + m_arg2.toString() + ")";
|
||||
}
|
||||
|
||||
virtual int precedence() const { return 100; }
|
||||
int precedence() const override { return 100; }
|
||||
|
||||
private:
|
||||
string m_name;
|
||||
|
@ -1146,7 +1138,7 @@ AddDirectionalLightContrib(unsigned int i, const ShaderProperties& props)
|
|||
}
|
||||
}
|
||||
|
||||
if ((props.texUsage & ShaderProperties::NightTexture) && VSComputesColorSum(props))
|
||||
if (((props.texUsage & ShaderProperties::NightTexture) != 0) && VSComputesColorSum(props))
|
||||
{
|
||||
source += "totalLight += NL * " + LightProperty(i, "brightness") + ";\n";
|
||||
}
|
||||
|
@ -1257,7 +1249,7 @@ ShadowsForLightSource(const ShaderProperties& props, unsigned int light)
|
|||
|
||||
|
||||
static string
|
||||
ScatteringPhaseFunctions(const ShaderProperties&)
|
||||
ScatteringPhaseFunctions(const ShaderProperties& /*unused*/)
|
||||
{
|
||||
string source;
|
||||
|
||||
|
@ -1843,7 +1835,7 @@ ShaderManager::buildVertexShader(const ShaderProperties& props)
|
|||
nTexCoords++;
|
||||
}
|
||||
|
||||
if (props.hasEclipseShadows() != 0)
|
||||
if (props.hasEclipseShadows())
|
||||
{
|
||||
source += "position_obj = gl_Vertex.xyz;\n";
|
||||
}
|
||||
|
@ -1854,19 +1846,16 @@ ShaderManager::buildVertexShader(const ShaderProperties& props)
|
|||
source += "gl_Position = ftransform();\n";
|
||||
source += "}\n";
|
||||
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Vertex shader source:\n";
|
||||
DumpShaderSource(*g_shaderLogFile, source);
|
||||
*g_shaderLogFile << '\n';
|
||||
}
|
||||
|
||||
GLVertexShader* vs = NULL;
|
||||
GLVertexShader* vs = nullptr;
|
||||
GLShaderStatus status = GLShaderLoader::CreateVertexShader(source, &vs);
|
||||
if (status != ShaderStatus_OK)
|
||||
return NULL;
|
||||
else
|
||||
return vs;
|
||||
return status == ShaderStatus_OK ? vs : nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2280,19 +2269,16 @@ ShaderManager::buildFragmentShader(const ShaderProperties& props)
|
|||
|
||||
source += "}\n";
|
||||
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Fragment shader source:\n";
|
||||
DumpShaderSource(*g_shaderLogFile, source);
|
||||
*g_shaderLogFile << '\n';
|
||||
}
|
||||
|
||||
GLFragmentShader* fs = NULL;
|
||||
GLFragmentShader* fs = nullptr;
|
||||
GLShaderStatus status = GLShaderLoader::CreateFragmentShader(source, &fs);
|
||||
if (status != ShaderStatus_OK)
|
||||
return NULL;
|
||||
else
|
||||
return fs;
|
||||
return status == ShaderStatus_OK ? fs : nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2343,17 +2329,17 @@ ShaderManager::buildRingsVertexShader(const ShaderProperties& props)
|
|||
source += "gl_Position = ftransform();\n";
|
||||
source += "}\n";
|
||||
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Vertex shader source:\n";
|
||||
DumpShaderSource(*g_shaderLogFile, source);
|
||||
*g_shaderLogFile << '\n';
|
||||
}
|
||||
|
||||
GLVertexShader* vs = NULL;
|
||||
GLVertexShader* vs = nullptr;
|
||||
GLShaderStatus status = GLShaderLoader::CreateVertexShader(source, &vs);
|
||||
if (status != ShaderStatus_OK)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
else
|
||||
return vs;
|
||||
}
|
||||
|
@ -2436,19 +2422,16 @@ ShaderManager::buildRingsFragmentShader(const ShaderProperties& props)
|
|||
|
||||
source += "}\n";
|
||||
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Fragment shader source:\n";
|
||||
DumpShaderSource(*g_shaderLogFile, source);
|
||||
*g_shaderLogFile << '\n';
|
||||
}
|
||||
|
||||
GLFragmentShader* fs = NULL;
|
||||
GLFragmentShader* fs = nullptr;
|
||||
GLShaderStatus status = GLShaderLoader::CreateFragmentShader(source, &fs);
|
||||
if (status != ShaderStatus_OK)
|
||||
return NULL;
|
||||
else
|
||||
return fs;
|
||||
return status == ShaderStatus_OK ? fs : nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2475,7 +2458,7 @@ ShaderManager::buildRingsVertexShader(const ShaderProperties& props)
|
|||
source += "diffTexCoord = " + TexCoord2D(0) + ";\n";
|
||||
|
||||
source += "position_obj = gl_Vertex.xyz;\n";
|
||||
if (props.hasEclipseShadows() != 0)
|
||||
if (props.hasEclipseShadows())
|
||||
{
|
||||
for (unsigned int i = 0; i < props.nLights; i++)
|
||||
{
|
||||
|
@ -2487,19 +2470,16 @@ ShaderManager::buildRingsVertexShader(const ShaderProperties& props)
|
|||
source += "gl_Position = ftransform();\n";
|
||||
source += "}\n";
|
||||
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Vertex shader source (rings):\n";
|
||||
DumpShaderSource(*g_shaderLogFile, source);
|
||||
*g_shaderLogFile << '\n';
|
||||
}
|
||||
|
||||
GLVertexShader* vs = NULL;
|
||||
GLVertexShader* vs = nullptr;
|
||||
GLShaderStatus status = GLShaderLoader::CreateVertexShader(source, &vs);
|
||||
if (status != ShaderStatus_OK)
|
||||
return NULL;
|
||||
else
|
||||
return vs;
|
||||
return status == ShaderStatus_OK ? vs : nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2605,19 +2585,16 @@ ShaderManager::buildRingsFragmentShader(const ShaderProperties& props)
|
|||
|
||||
source += "}\n";
|
||||
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Fragment shader source (rings):\n";
|
||||
DumpShaderSource(*g_shaderLogFile, source);
|
||||
*g_shaderLogFile << '\n';
|
||||
}
|
||||
|
||||
GLFragmentShader* fs = NULL;
|
||||
GLFragmentShader* fs = nullptr;
|
||||
GLShaderStatus status = GLShaderLoader::CreateFragmentShader(source, &fs);
|
||||
if (status != ShaderStatus_OK)
|
||||
return NULL;
|
||||
else
|
||||
return fs;
|
||||
return status == ShaderStatus_OK ? fs : nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2650,19 +2627,16 @@ ShaderManager::buildAtmosphereVertexShader(const ShaderProperties& props)
|
|||
source += "gl_Position = ftransform();\n";
|
||||
source += "}\n";
|
||||
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Vertex shader source:\n";
|
||||
DumpShaderSource(*g_shaderLogFile, source);
|
||||
*g_shaderLogFile << '\n';
|
||||
}
|
||||
|
||||
GLVertexShader* vs = NULL;
|
||||
GLVertexShader* vs = nullptr;
|
||||
GLShaderStatus status = GLShaderLoader::CreateVertexShader(source, &vs);
|
||||
if (status != ShaderStatus_OK)
|
||||
return NULL;
|
||||
else
|
||||
return vs;
|
||||
return status == ShaderStatus_OK ? vs : nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2709,19 +2683,16 @@ ShaderManager::buildAtmosphereFragmentShader(const ShaderProperties& props)
|
|||
source += " gl_FragColor = vec4(color, dot(scatterEx, vec3(0.333, 0.333, 0.333)));\n";
|
||||
source += "}\n";
|
||||
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Fragment shader source:\n";
|
||||
DumpShaderSource(*g_shaderLogFile, source);
|
||||
*g_shaderLogFile << '\n';
|
||||
}
|
||||
|
||||
GLFragmentShader* fs = NULL;
|
||||
GLFragmentShader* fs = nullptr;
|
||||
GLShaderStatus status = GLShaderLoader::CreateFragmentShader(source, &fs);
|
||||
if (status != ShaderStatus_OK)
|
||||
return NULL;
|
||||
else
|
||||
return fs;
|
||||
return status == ShaderStatus_OK ? fs : nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2781,19 +2752,16 @@ ShaderManager::buildEmissiveVertexShader(const ShaderProperties& props)
|
|||
source += "}\n";
|
||||
// End of main()
|
||||
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Vertex shader source:\n";
|
||||
DumpShaderSource(*g_shaderLogFile, source);
|
||||
*g_shaderLogFile << '\n';
|
||||
}
|
||||
|
||||
GLVertexShader* vs = NULL;
|
||||
GLVertexShader* vs = nullptr;
|
||||
GLShaderStatus status = GLShaderLoader::CreateVertexShader(source, &vs);
|
||||
if (status != ShaderStatus_OK)
|
||||
return NULL;
|
||||
else
|
||||
return vs;
|
||||
return status == ShaderStatus_OK ? vs : nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2838,19 +2806,16 @@ ShaderManager::buildEmissiveFragmentShader(const ShaderProperties& props)
|
|||
source += "}\n";
|
||||
// End of main()
|
||||
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Fragment shader source:\n";
|
||||
DumpShaderSource(*g_shaderLogFile, source);
|
||||
*g_shaderLogFile << '\n';
|
||||
}
|
||||
|
||||
GLFragmentShader* fs = NULL;
|
||||
GLFragmentShader* fs = nullptr;
|
||||
GLShaderStatus status = GLShaderLoader::CreateFragmentShader(source, &fs);
|
||||
if (status != ShaderStatus_OK)
|
||||
return NULL;
|
||||
else
|
||||
return fs;
|
||||
return status != ShaderStatus_OK ? nullptr : fs;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2926,19 +2891,16 @@ ShaderManager::buildParticleVertexShader(const ShaderProperties& props)
|
|||
source << "}\n";
|
||||
// End of main()
|
||||
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Vertex shader source:\n";
|
||||
DumpShaderSource(*g_shaderLogFile, source.str());
|
||||
*g_shaderLogFile << endl;
|
||||
}
|
||||
|
||||
GLVertexShader* vs = NULL;
|
||||
GLVertexShader* vs = nullptr;
|
||||
GLShaderStatus status = GLShaderLoader::CreateVertexShader(source.str(), &vs);
|
||||
if (status != ShaderStatus_OK)
|
||||
return NULL;
|
||||
else
|
||||
return vs;
|
||||
return status == ShaderStatus_OK ? vs : nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2995,30 +2957,27 @@ ShaderManager::buildParticleFragmentShader(const ShaderProperties& props)
|
|||
source << "}\n";
|
||||
// End of main()
|
||||
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
{
|
||||
*g_shaderLogFile << "Fragment shader source:\n";
|
||||
DumpShaderSource(*g_shaderLogFile, source.str());
|
||||
*g_shaderLogFile << '\n';
|
||||
}
|
||||
|
||||
GLFragmentShader* fs = NULL;
|
||||
GLFragmentShader* fs = nullptr;
|
||||
GLShaderStatus status = GLShaderLoader::CreateFragmentShader(source.str(), &fs);
|
||||
if (status != ShaderStatus_OK)
|
||||
return NULL;
|
||||
else
|
||||
return fs;
|
||||
return status == ShaderStatus_OK ? fs : nullptr;
|
||||
}
|
||||
|
||||
|
||||
CelestiaGLProgram*
|
||||
ShaderManager::buildProgram(const ShaderProperties& props)
|
||||
{
|
||||
GLProgram* prog = NULL;
|
||||
GLProgram* prog = nullptr;
|
||||
GLShaderStatus status;
|
||||
|
||||
GLVertexShader* vs = NULL;
|
||||
GLFragmentShader* fs = NULL;
|
||||
GLVertexShader* vs = nullptr;
|
||||
GLFragmentShader* fs = nullptr;
|
||||
|
||||
if (props.lightModel == ShaderProperties::RingIllumModel)
|
||||
{
|
||||
|
@ -3046,7 +3005,7 @@ ShaderManager::buildProgram(const ShaderProperties& props)
|
|||
fs = buildFragmentShader(props);
|
||||
}
|
||||
|
||||
if (vs != NULL && fs != NULL)
|
||||
if (vs != nullptr && fs != nullptr)
|
||||
{
|
||||
status = GLShaderLoader::CreateProgram(*vs, *fs, &prog);
|
||||
if (status == ShaderStatus_OK)
|
||||
|
@ -3084,7 +3043,7 @@ ShaderManager::buildProgram(const ShaderProperties& props)
|
|||
&prog);
|
||||
if (status != ShaderStatus_OK)
|
||||
{
|
||||
if (g_shaderLogFile != NULL)
|
||||
if (g_shaderLogFile != nullptr)
|
||||
*g_shaderLogFile << "Failed to create error shader!\n";
|
||||
}
|
||||
else
|
||||
|
@ -3093,10 +3052,10 @@ ShaderManager::buildProgram(const ShaderProperties& props)
|
|||
}
|
||||
}
|
||||
|
||||
if (prog == NULL)
|
||||
return NULL;
|
||||
else
|
||||
return new CelestiaGLProgram(*prog, props);
|
||||
if (prog == nullptr)
|
||||
return nullptr;
|
||||
|
||||
return new CelestiaGLProgram(*prog, props);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3380,7 +3339,7 @@ CelestiaGLProgram::setEclipseShadowParameters(const LightingState& ls,
|
|||
li < min(ls.nLights, MaxShaderLights);
|
||||
li++)
|
||||
{
|
||||
if (ls.shadows[li] != NULL)
|
||||
if (ls.shadows[li] != nullptr)
|
||||
{
|
||||
unsigned int nShadows = min((size_t) MaxShaderEclipseShadows, ls.shadows[li]->size());
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ class ShaderManager
|
|||
{
|
||||
public:
|
||||
ShaderManager();
|
||||
~ShaderManager();
|
||||
~ShaderManager() = default;
|
||||
|
||||
CelestiaGLProgram* getShader(const ShaderProperties&);
|
||||
|
||||
|
|
|
@ -19,15 +19,7 @@ using namespace std;
|
|||
|
||||
|
||||
Simulation::Simulation(Universe* _universe) :
|
||||
realTime(0.0),
|
||||
timeScale(1.0),
|
||||
storedTimeScale(1.0),
|
||||
syncTime(true),
|
||||
universe(_universe),
|
||||
closestSolarSystem(NULL),
|
||||
selection(),
|
||||
faintestVisible(5.0f),
|
||||
pauseState(false)
|
||||
universe(_universe)
|
||||
{
|
||||
activeObserver = new Observer();
|
||||
observers.insert(observers.end(), activeObserver);
|
||||
|
@ -36,21 +28,15 @@ Simulation::Simulation(Universe* _universe) :
|
|||
|
||||
Simulation::~Simulation()
|
||||
{
|
||||
for (vector<Observer*>::iterator iter = observers.begin();
|
||||
iter != observers.end(); iter++)
|
||||
{
|
||||
delete *iter;
|
||||
}
|
||||
for (const auto observer : observers)
|
||||
delete observer;
|
||||
}
|
||||
|
||||
|
||||
static const Star* getSun(Body* body)
|
||||
{
|
||||
PlanetarySystem* system = body->getSystem();
|
||||
if (system == NULL)
|
||||
return NULL;
|
||||
else
|
||||
return system->getStar();
|
||||
return system ? system->getStar() : nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,10 +83,9 @@ void Simulation::setTime(double jd)
|
|||
{
|
||||
if (syncTime)
|
||||
{
|
||||
for (vector<Observer*>::iterator iter = observers.begin();
|
||||
iter != observers.end(); iter++)
|
||||
for (const auto observer : observers)
|
||||
{
|
||||
(*iter)->setTime(jd);
|
||||
observer->setTime(jd);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -128,10 +113,9 @@ void Simulation::update(double dt)
|
|||
{
|
||||
realTime += dt;
|
||||
|
||||
for (vector<Observer*>::iterator iter = observers.begin();
|
||||
iter != observers.end(); iter++)
|
||||
for (const auto observer : observers)
|
||||
{
|
||||
(*iter)->update(dt, timeScale);
|
||||
observer->update(dt, timeScale);
|
||||
}
|
||||
|
||||
// Find the closest solar system
|
||||
|
@ -195,7 +179,7 @@ Observer* Simulation::addObserver()
|
|||
|
||||
void Simulation::removeObserver(Observer* o)
|
||||
{
|
||||
vector<Observer*>::iterator iter = find(observers.begin(), observers.end(), o);
|
||||
auto iter = find(observers.begin(), observers.end(), o);
|
||||
if (iter != observers.end())
|
||||
observers.erase(iter);
|
||||
}
|
||||
|
@ -209,7 +193,7 @@ Observer* Simulation::getActiveObserver()
|
|||
|
||||
void Simulation::setActiveObserver(Observer* o)
|
||||
{
|
||||
vector<Observer*>::iterator iter= find(observers.begin(), observers.end(), o);
|
||||
auto iter = find(observers.begin(), observers.end(), o);
|
||||
if (iter != observers.end())
|
||||
activeObserver = o;
|
||||
}
|
||||
|
@ -390,25 +374,25 @@ void Simulation::selectPlanet(int index)
|
|||
if (selection.getType() == Selection::Type_Body)
|
||||
{
|
||||
PlanetarySystem* system = selection.body()->getSystem();
|
||||
if (system != NULL)
|
||||
if (system != nullptr)
|
||||
setSelection(system->getStar());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const Star* star = NULL;
|
||||
const Star* star = nullptr;
|
||||
if (selection.getType() == Selection::Type_Star)
|
||||
star = selection.star();
|
||||
else if (selection.getType() == Selection::Type_Body)
|
||||
star = getSun(selection.body());
|
||||
|
||||
SolarSystem* solarSystem = NULL;
|
||||
if (star != NULL)
|
||||
SolarSystem* solarSystem = nullptr;
|
||||
if (star != nullptr)
|
||||
solarSystem = universe->getSolarSystem(star);
|
||||
else
|
||||
solarSystem = closestSolarSystem;
|
||||
|
||||
if (solarSystem != NULL &&
|
||||
if (solarSystem != nullptr &&
|
||||
index < solarSystem->getPlanets()->getSystemSize())
|
||||
{
|
||||
setSelection(Selection(solarSystem->getPlanets()->getBody(index)));
|
||||
|
@ -431,7 +415,7 @@ Selection Simulation::findObject(string s, bool i18n)
|
|||
if (!selection.empty())
|
||||
path[nPathEntries++] = selection;
|
||||
|
||||
if (closestSolarSystem != NULL)
|
||||
if (closestSolarSystem != nullptr)
|
||||
path[nPathEntries++] = Selection(closestSolarSystem->getStar());
|
||||
|
||||
return universe->find(s, path, nPathEntries, i18n);
|
||||
|
@ -449,7 +433,7 @@ Selection Simulation::findObjectFromPath(string s, bool i18n)
|
|||
if (!selection.empty())
|
||||
path[nPathEntries++] = selection;
|
||||
|
||||
if (closestSolarSystem != NULL)
|
||||
if (closestSolarSystem != nullptr)
|
||||
path[nPathEntries++] = Selection(closestSolarSystem->getStar());
|
||||
|
||||
return universe->findPath(s, path, nPathEntries, i18n);
|
||||
|
@ -472,7 +456,7 @@ vector<std::string> Simulation::getObjectCompletion(string s, bool withLocations
|
|||
}
|
||||
}
|
||||
|
||||
if (closestSolarSystem != NULL &&
|
||||
if (closestSolarSystem != nullptr &&
|
||||
closestSolarSystem != universe->getSolarSystem(selection))
|
||||
{
|
||||
path[nPathEntries++] = Selection(closestSolarSystem->getStar());
|
||||
|
@ -489,7 +473,7 @@ double Simulation::getTimeScale() const
|
|||
|
||||
void Simulation::setTimeScale(double _timeScale)
|
||||
{
|
||||
if (pauseState == true)
|
||||
if (pauseState)
|
||||
{
|
||||
storedTimeScale = _timeScale;
|
||||
}
|
||||
|
@ -519,7 +503,7 @@ void Simulation::setPauseState(bool state)
|
|||
if (pauseState == state) return;
|
||||
|
||||
pauseState = state;
|
||||
if (pauseState == true)
|
||||
if (pauseState)
|
||||
{
|
||||
storedTimeScale = timeScale;
|
||||
timeScale = 0.0;
|
||||
|
@ -533,10 +517,9 @@ void Simulation::setPauseState(bool state)
|
|||
// Synchronize all observers to active observer time
|
||||
void Simulation::synchronizeTime()
|
||||
{
|
||||
for (vector<Observer*>::iterator iter = observers.begin();
|
||||
iter != observers.end(); iter++)
|
||||
for (const auto observer : observers)
|
||||
{
|
||||
(*iter)->setTime(activeObserver->getTime());
|
||||
observer->setTime(activeObserver->getTime());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class Simulation
|
|||
~Simulation();
|
||||
|
||||
double getTime() const; // Julian date
|
||||
void setTime(double t);
|
||||
void setTime(double jd);
|
||||
|
||||
double getRealTime() const;
|
||||
double getArrivalTime() const;
|
||||
|
@ -121,21 +121,21 @@ class Simulation
|
|||
SolarSystem* getSolarSystem(const Star* star);
|
||||
|
||||
private:
|
||||
double realTime;
|
||||
double timeScale;
|
||||
double storedTimeScale;
|
||||
bool syncTime;
|
||||
double realTime{ 0.0 };
|
||||
double timeScale{ 1.0 };
|
||||
double storedTimeScale{ 1.0 };
|
||||
bool syncTime{ true };
|
||||
|
||||
Universe* universe;
|
||||
|
||||
SolarSystem* closestSolarSystem;
|
||||
SolarSystem* closestSolarSystem{ nullptr };
|
||||
Selection selection;
|
||||
|
||||
Observer* activeObserver;
|
||||
std::vector<Observer*> observers;
|
||||
|
||||
float faintestVisible;
|
||||
bool pauseState;
|
||||
float faintestVisible{ 5.0f };
|
||||
bool pauseState{ false };
|
||||
};
|
||||
|
||||
#endif // _CELENGINE_SIMULATION_H_
|
||||
|
|
|
@ -136,21 +136,6 @@ static const int DEG_MIN_SEC_STEPS[] =
|
|||
#endif
|
||||
|
||||
|
||||
SkyGrid::SkyGrid() :
|
||||
m_orientation(Quaterniond::Identity()),
|
||||
m_lineColor(Color::White),
|
||||
m_labelColor(Color::White),
|
||||
m_longitudeUnits(LongitudeHours),
|
||||
m_longitudeDirection(IncreasingCounterclockwise)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SkyGrid::~SkyGrid()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static Vector3d
|
||||
toStandardCoords(const Vector3d& v)
|
||||
{
|
||||
|
@ -206,10 +191,7 @@ getCoordLabelHAlign(int planeIndex)
|
|||
static Renderer::LabelVerticalAlignment
|
||||
getCoordLabelVAlign(int planeIndex)
|
||||
{
|
||||
if (planeIndex == 1)
|
||||
return Renderer::VerticalAlignTop;
|
||||
else
|
||||
return Renderer::VerticalAlignBottom;
|
||||
return planeIndex == 1 ? Renderer::VerticalAlignTop : Renderer::VerticalAlignBottom;
|
||||
}
|
||||
|
||||
|
||||
|
@ -424,7 +406,7 @@ SkyGrid::render(Renderer& renderer,
|
|||
double cosHalfFov = 1.0 / diag;
|
||||
double halfFov = acos(cosHalfFov);
|
||||
|
||||
float polarCrossSize = (float) (POLAR_CROSS_SIZE * halfFov);
|
||||
auto polarCrossSize = (float) (POLAR_CROSS_SIZE * halfFov);
|
||||
|
||||
// We want to avoid drawing more of the grid than we have to. The following code
|
||||
// determines the region of the grid intersected by the view frustum. We're
|
||||
|
@ -580,9 +562,9 @@ SkyGrid::render(Renderer& renderer,
|
|||
for (int j = 0; j <= ARC_SUBDIVISIONS; j++)
|
||||
{
|
||||
double theta = theta0 + j * arcStep;
|
||||
float x = (float) (cosPhi * std::cos(theta));
|
||||
float y = (float) (cosPhi * std::sin(theta));
|
||||
float z = (float) sinPhi;
|
||||
auto x = (float) (cosPhi * std::cos(theta));
|
||||
auto y = (float) (cosPhi * std::sin(theta));
|
||||
auto z = (float) sinPhi;
|
||||
glVertex3f(x, z, -y); // convert to Celestia coords
|
||||
}
|
||||
glEnd();
|
||||
|
@ -623,12 +605,12 @@ SkyGrid::render(Renderer& renderer,
|
|||
|
||||
if ((m * p0).z() < 0.0)
|
||||
{
|
||||
renderer.addBackgroundAnnotation(NULL, labelText, m_labelColor, p0, hAlign, vAlign);
|
||||
renderer.addBackgroundAnnotation(nullptr, labelText, m_labelColor, p0, hAlign, vAlign);
|
||||
}
|
||||
|
||||
if ((m * p1).z() < 0.0)
|
||||
{
|
||||
renderer.addBackgroundAnnotation(NULL, labelText, m_labelColor, p1, hAlign, vAlign);
|
||||
renderer.addBackgroundAnnotation(nullptr, labelText, m_labelColor, p1, hAlign, vAlign);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -656,9 +638,9 @@ SkyGrid::render(Renderer& renderer,
|
|||
for (int j = 0; j <= ARC_SUBDIVISIONS; j++)
|
||||
{
|
||||
double phi = phi0 + j * arcStep;
|
||||
float x = (float) (cos(phi) * cosTheta);
|
||||
float y = (float) (cos(phi) * sinTheta);
|
||||
float z = (float) sin(phi);
|
||||
auto x = (float) (cos(phi) * cosTheta);
|
||||
auto y = (float) (cos(phi) * sinTheta);
|
||||
auto z = (float) sin(phi);
|
||||
glVertex3f(x, z, -y); // convert to Celestia coords
|
||||
}
|
||||
glEnd();
|
||||
|
@ -699,12 +681,12 @@ SkyGrid::render(Renderer& renderer,
|
|||
|
||||
if ((m * p0).z() < 0.0 && axis0.dot(isect0) >= cosMaxMeridianAngle)
|
||||
{
|
||||
renderer.addBackgroundAnnotation(NULL, labelText, m_labelColor, p0, hAlign, vAlign);
|
||||
renderer.addBackgroundAnnotation(nullptr, labelText, m_labelColor, p0, hAlign, vAlign);
|
||||
}
|
||||
|
||||
if ((m * p1).z() < 0.0 && axis0.dot(isect1) >= cosMaxMeridianAngle)
|
||||
{
|
||||
renderer.addBackgroundAnnotation(NULL, labelText, m_labelColor, p1, hAlign, vAlign);
|
||||
renderer.addBackgroundAnnotation(nullptr, labelText, m_labelColor, p1, hAlign, vAlign);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ public:
|
|||
IncreasingClockwise,
|
||||
};
|
||||
|
||||
SkyGrid();
|
||||
~SkyGrid();
|
||||
SkyGrid() = default;
|
||||
~SkyGrid() = default;
|
||||
|
||||
void render(Renderer& renderer,
|
||||
const Observer& observer,
|
||||
|
@ -108,11 +108,11 @@ private:
|
|||
int meridianSpacing(double idealSpacing) const;
|
||||
|
||||
private:
|
||||
Eigen::Quaterniond m_orientation;
|
||||
Color m_lineColor;
|
||||
Color m_labelColor;
|
||||
LongitudeUnits m_longitudeUnits;
|
||||
LongitudeDirection m_longitudeDirection;
|
||||
Eigen::Quaterniond m_orientation{ Eigen::Quaterniond::Identity() };
|
||||
Color m_lineColor{ Color::White };
|
||||
Color m_labelColor{ Color::White };
|
||||
LongitudeUnits m_longitudeUnits{ LongitudeHours };
|
||||
LongitudeDirection m_longitudeDirection{ IncreasingCounterclockwise };
|
||||
};
|
||||
|
||||
#endif // _CELENGINE_PLANETGRID_H_
|
||||
|
|
|
@ -145,8 +145,8 @@ int GetClassificationId(const string& className)
|
|||
ClassificationTable::iterator iter = Classifications.find(className);
|
||||
if (iter == Classifications.end())
|
||||
return Body::Unknown;
|
||||
else
|
||||
return iter->second;
|
||||
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
|
||||
|
@ -291,7 +291,7 @@ static Selection GetParentObject(PlanetarySystem* system)
|
|||
{
|
||||
Selection parent;
|
||||
Body* primary = system->getPrimaryBody();
|
||||
if (primary != NULL)
|
||||
if (primary != nullptr)
|
||||
parent = Selection(primary);
|
||||
else
|
||||
parent = Selection(system->getStar());
|
||||
|
@ -320,7 +320,7 @@ TimelinePhase* CreateTimelinePhase(Body* body,
|
|||
if (!isFirstPhase && hasBeginning)
|
||||
{
|
||||
clog << "Error: Beginning can only be specified for initial phase of timeline.\n";
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Ending is required for all phases except for the final one.
|
||||
|
@ -328,18 +328,18 @@ TimelinePhase* CreateTimelinePhase(Body* body,
|
|||
if (!isLastPhase && !hasEnding)
|
||||
{
|
||||
clog << "Error: Ending is required for all timeline phases other than the final one.\n";
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Get the orbit reference frame.
|
||||
ReferenceFrame* orbitFrame;
|
||||
Value* frameValue = phaseData->getValue("OrbitFrame");
|
||||
if (frameValue != NULL)
|
||||
if (frameValue != nullptr)
|
||||
{
|
||||
orbitFrame = CreateReferenceFrame(universe, frameValue, defaultOrbitFrame->getCenter(), body);
|
||||
if (orbitFrame == NULL)
|
||||
if (orbitFrame == nullptr)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -352,13 +352,13 @@ TimelinePhase* CreateTimelinePhase(Body* body,
|
|||
// Get the body reference frame
|
||||
ReferenceFrame* bodyFrame;
|
||||
Value* bodyFrameValue = phaseData->getValue("BodyFrame");
|
||||
if (bodyFrameValue != NULL)
|
||||
if (bodyFrameValue != nullptr)
|
||||
{
|
||||
bodyFrame = CreateReferenceFrame(universe, bodyFrameValue, defaultBodyFrame->getCenter(), body);
|
||||
if (bodyFrame == NULL)
|
||||
if (bodyFrame == nullptr)
|
||||
{
|
||||
orbitFrame->release();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -370,7 +370,7 @@ TimelinePhase* CreateTimelinePhase(Body* body,
|
|||
|
||||
// Use planet units (AU for semimajor axis) if the center of the orbit
|
||||
// reference frame is a star.
|
||||
bool usePlanetUnits = orbitFrame->getCenter().star() != NULL;
|
||||
bool usePlanetUnits = orbitFrame->getCenter().star() != nullptr;
|
||||
|
||||
// Get the orbit
|
||||
Orbit* orbit = CreateOrbit(orbitFrame->getCenter(), phaseData, path, usePlanetUnits);
|
||||
|
@ -379,7 +379,7 @@ TimelinePhase* CreateTimelinePhase(Body* body,
|
|||
clog << "Error: missing orbit in timeline phase.\n";
|
||||
bodyFrame->release();
|
||||
orbitFrame->release();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Get the rotation model
|
||||
|
@ -417,17 +417,17 @@ Timeline* CreateTimelineFromArray(Body* body,
|
|||
ReferenceFrame* defaultOrbitFrame,
|
||||
ReferenceFrame* defaultBodyFrame)
|
||||
{
|
||||
Timeline* timeline = new Timeline();
|
||||
auto* timeline = new Timeline();
|
||||
double previousEnding = -numeric_limits<double>::infinity();
|
||||
|
||||
for (ValueArray::const_iterator iter = timelineArray->begin(); iter != timelineArray->end(); iter++)
|
||||
{
|
||||
Hash* phaseData = (*iter)->getHash();
|
||||
if (phaseData == NULL)
|
||||
if (phaseData == nullptr)
|
||||
{
|
||||
clog << "Error in timeline of '" << body->getName() << "': phase " << iter - timelineArray->begin() + 1 << " is not a property group.\n";
|
||||
delete timeline;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool isFirstPhase = iter == timelineArray->begin();
|
||||
|
@ -438,11 +438,11 @@ Timeline* CreateTimelineFromArray(Body* body,
|
|||
defaultOrbitFrame,
|
||||
defaultBodyFrame,
|
||||
isFirstPhase, isLastPhase, previousEnding);
|
||||
if (phase == NULL)
|
||||
if (phase == nullptr)
|
||||
{
|
||||
clog << "Error in timeline of '" << body->getName() << "', phase " << iter - timelineArray->begin() + 1 << endl;
|
||||
delete timeline;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
previousEnding = phase->endTime();
|
||||
|
@ -462,7 +462,7 @@ static bool CreateTimeline(Body* body,
|
|||
Disposition disposition,
|
||||
BodyType bodyType)
|
||||
{
|
||||
FrameTree* parentFrameTree = NULL;
|
||||
FrameTree* parentFrameTree = nullptr;
|
||||
Selection parentObject = GetParentObject(system);
|
||||
bool orbitsPlanet = false;
|
||||
if (parentObject.body())
|
||||
|
@ -473,7 +473,7 @@ static bool CreateTimeline(Body* body,
|
|||
else if (parentObject.star())
|
||||
{
|
||||
SolarSystem* solarSystem = universe.getSolarSystem(parentObject.star());
|
||||
if (solarSystem == NULL)
|
||||
if (solarSystem == nullptr)
|
||||
solarSystem = universe.createSolarSystem(parentObject.star());
|
||||
parentFrameTree = solarSystem->getFrameTree();
|
||||
}
|
||||
|
@ -483,8 +483,8 @@ static bool CreateTimeline(Body* body,
|
|||
return false;
|
||||
}
|
||||
|
||||
ReferenceFrame* defaultOrbitFrame = NULL;
|
||||
ReferenceFrame* defaultBodyFrame = NULL;
|
||||
ReferenceFrame* defaultOrbitFrame = nullptr;
|
||||
ReferenceFrame* defaultBodyFrame = nullptr;
|
||||
if (bodyType == SurfaceObject)
|
||||
{
|
||||
defaultOrbitFrame = new BodyFixedFrame(parentObject, parentObject);
|
||||
|
@ -501,7 +501,7 @@ static bool CreateTimeline(Body* body,
|
|||
// If there's an explicit timeline definition, parse that. Otherwise, we'll do
|
||||
// things the old way.
|
||||
Value* value = planetData->getValue("Timeline");
|
||||
if (value != NULL)
|
||||
if (value != nullptr)
|
||||
{
|
||||
if (value->getType() != Value::ArrayType)
|
||||
{
|
||||
|
@ -511,22 +511,19 @@ static bool CreateTimeline(Body* body,
|
|||
|
||||
Timeline* timeline = CreateTimelineFromArray(body, universe, value->getArray(), path,
|
||||
defaultOrbitFrame, defaultBodyFrame);
|
||||
if (timeline == NULL)
|
||||
{
|
||||
|
||||
if (!timeline)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
body->setTimeline(timeline);
|
||||
return true;
|
||||
}
|
||||
|
||||
body->setTimeline(timeline);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Information required for the object timeline.
|
||||
ReferenceFrame* orbitFrame = NULL;
|
||||
ReferenceFrame* bodyFrame = NULL;
|
||||
Orbit* orbit = NULL;
|
||||
RotationModel* rotationModel = NULL;
|
||||
ReferenceFrame* orbitFrame = nullptr;
|
||||
ReferenceFrame* bodyFrame = nullptr;
|
||||
Orbit* orbit = nullptr;
|
||||
RotationModel* rotationModel = nullptr;
|
||||
double beginning = -numeric_limits<double>::infinity();
|
||||
double ending = numeric_limits<double>::infinity();
|
||||
|
||||
|
@ -558,10 +555,10 @@ static bool CreateTimeline(Body* body,
|
|||
// Get the object's orbit reference frame.
|
||||
bool newOrbitFrame = false;
|
||||
Value* frameValue = planetData->getValue("OrbitFrame");
|
||||
if (frameValue != NULL)
|
||||
if (frameValue != nullptr)
|
||||
{
|
||||
ReferenceFrame* frame = CreateReferenceFrame(universe, frameValue, parentObject, body);
|
||||
if (frame != NULL)
|
||||
if (frame != nullptr)
|
||||
{
|
||||
orbitFrame = frame;
|
||||
newOrbitFrame = true;
|
||||
|
@ -572,10 +569,10 @@ static bool CreateTimeline(Body* body,
|
|||
// Get the object's body frame.
|
||||
bool newBodyFrame = false;
|
||||
Value* bodyFrameValue = planetData->getValue("BodyFrame");
|
||||
if (bodyFrameValue != NULL)
|
||||
if (bodyFrameValue != nullptr)
|
||||
{
|
||||
ReferenceFrame* frame = CreateReferenceFrame(universe, bodyFrameValue, parentObject, body);
|
||||
if (frame != NULL)
|
||||
if (frame != nullptr)
|
||||
{
|
||||
bodyFrame = frame;
|
||||
newBodyFrame = true;
|
||||
|
@ -584,20 +581,17 @@ static bool CreateTimeline(Body* body,
|
|||
}
|
||||
|
||||
// If no orbit or body frame was specified, use the default ones
|
||||
if (orbitFrame == NULL)
|
||||
if (orbitFrame == nullptr)
|
||||
orbitFrame = defaultOrbitFrame;
|
||||
if (bodyFrame == NULL)
|
||||
if (bodyFrame == nullptr)
|
||||
bodyFrame = defaultBodyFrame;
|
||||
|
||||
// If the center of the is a star, orbital element units are
|
||||
// in AU; otherwise, use kilometers.
|
||||
if (orbitFrame->getCenter().star() != NULL)
|
||||
orbitsPlanet = false;
|
||||
else
|
||||
orbitsPlanet = true;
|
||||
orbitsPlanet = orbitFrame->getCenter().star() == nullptr;
|
||||
|
||||
Orbit* newOrbit = CreateOrbit(orbitFrame->getCenter(), planetData, path, !orbitsPlanet);
|
||||
if (newOrbit == NULL && orbit == NULL)
|
||||
if (newOrbit == nullptr && orbit == nullptr)
|
||||
{
|
||||
if (body->getTimeline() && disposition == ModifyObject)
|
||||
{
|
||||
|
@ -617,7 +611,7 @@ static bool CreateTimeline(Body* body,
|
|||
}
|
||||
|
||||
// If a new orbit was given, override any old orbit
|
||||
if (newOrbit != NULL)
|
||||
if (newOrbit != nullptr)
|
||||
{
|
||||
orbit = newOrbit;
|
||||
overrideOldTimeline = true;
|
||||
|
@ -628,7 +622,7 @@ static bool CreateTimeline(Body* body,
|
|||
RotationModel* newRotationModel = CreateRotationModel(planetData, path, syncRotationPeriod);
|
||||
|
||||
// If a new rotation model was given, override the old one
|
||||
if (newRotationModel != NULL)
|
||||
if (newRotationModel != nullptr)
|
||||
{
|
||||
rotationModel = newRotationModel;
|
||||
overrideOldTimeline = true;
|
||||
|
@ -636,7 +630,7 @@ static bool CreateTimeline(Body* body,
|
|||
|
||||
// If there was no rotation model specified, nor a previous rotation model to
|
||||
// override, create the default one.
|
||||
if (rotationModel == NULL)
|
||||
if (rotationModel == nullptr)
|
||||
{
|
||||
// If no rotation model is provided, use a default rotation model--
|
||||
// a uniform rotation that's synchronous with the orbit (appropriate
|
||||
|
@ -673,14 +667,14 @@ static bool CreateTimeline(Body* body,
|
|||
|
||||
// We've already checked that beginning < ending; nothing else should go
|
||||
// wrong during the creation of a TimelinePhase.
|
||||
assert(phase != NULL);
|
||||
if (phase == NULL)
|
||||
assert(phase != nullptr);
|
||||
if (phase == nullptr)
|
||||
{
|
||||
clog << "Internal error creating TimelinePhase.\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
Timeline* timeline = new Timeline();
|
||||
auto* timeline = new Timeline();
|
||||
timeline->appendPhase(phase);
|
||||
|
||||
body->setTimeline(timeline);
|
||||
|
@ -718,14 +712,14 @@ static Body* CreateBody(const string& name,
|
|||
Disposition disposition,
|
||||
BodyType bodyType)
|
||||
{
|
||||
Body* body = NULL;
|
||||
Body* body = nullptr;
|
||||
|
||||
if (disposition == ModifyObject || disposition == ReplaceObject)
|
||||
{
|
||||
body = existingBody;
|
||||
}
|
||||
|
||||
if (body == NULL)
|
||||
if (body == nullptr)
|
||||
{
|
||||
body = new Body(system, name);
|
||||
// If the body doesn't exist, always treat the disposition as 'Add'
|
||||
|
@ -744,7 +738,7 @@ static Body* CreateBody(const string& name,
|
|||
// No valid timeline given; give up.
|
||||
if (body != existingBody)
|
||||
delete body;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Three values control the shape and size of an ellipsoidal object:
|
||||
|
@ -758,7 +752,7 @@ static Body* CreateBody(const string& name,
|
|||
// If the body also has a mesh, it is always scaled in x, y, and z by
|
||||
// the maximum semiaxis, never anisotropically.
|
||||
|
||||
double radius = (double) body->getRadius();
|
||||
auto radius = (double) body->getRadius();
|
||||
bool radiusSpecified = false;
|
||||
if (planetData->getLength("Radius", radius))
|
||||
{
|
||||
|
@ -801,7 +795,7 @@ static Body* CreateBody(const string& name,
|
|||
if (classification == Body::Unknown)
|
||||
{
|
||||
// Try to guess the type
|
||||
if (system->getPrimaryBody() != NULL)
|
||||
if (system->getPrimaryBody() != nullptr)
|
||||
{
|
||||
if(radius > 0.1)
|
||||
classification = Body::Moon;
|
||||
|
@ -899,7 +893,7 @@ static Body* CreateBody(const string& name,
|
|||
// Read the atmosphere
|
||||
{
|
||||
Value* atmosDataValue = planetData->getValue("Atmosphere");
|
||||
if (atmosDataValue != NULL)
|
||||
if (atmosDataValue != nullptr)
|
||||
{
|
||||
if (atmosDataValue->getType() != Value::HashType)
|
||||
{
|
||||
|
@ -908,13 +902,13 @@ static Body* CreateBody(const string& name,
|
|||
else
|
||||
{
|
||||
Hash* atmosData = atmosDataValue->getHash();
|
||||
assert(atmosData != NULL);
|
||||
assert(atmosData != nullptr);
|
||||
|
||||
Atmosphere* atmosphere = NULL;
|
||||
Atmosphere* atmosphere = nullptr;
|
||||
if (disposition == ModifyObject)
|
||||
{
|
||||
atmosphere = body->getAtmosphere();
|
||||
if (atmosphere == NULL)
|
||||
if (atmosphere == nullptr)
|
||||
{
|
||||
Atmosphere atm;
|
||||
body->setAtmosphere(atm);
|
||||
|
@ -976,7 +970,7 @@ static Body* CreateBody(const string& name,
|
|||
// Read the ring system
|
||||
{
|
||||
Value* ringsDataValue = planetData->getValue("Rings");
|
||||
if (ringsDataValue != NULL)
|
||||
if (ringsDataValue != nullptr)
|
||||
{
|
||||
if (ringsDataValue->getType() != Value::HashType)
|
||||
{
|
||||
|
@ -985,10 +979,10 @@ static Body* CreateBody(const string& name,
|
|||
else
|
||||
{
|
||||
Hash* ringsData = ringsDataValue->getHash();
|
||||
// ASSERT(ringsData != NULL);
|
||||
// ASSERT(ringsData != nullptr);
|
||||
|
||||
RingSystem rings(0.0f, 0.0f);
|
||||
if (body->getRings() != NULL)
|
||||
if (body->getRings() != nullptr)
|
||||
rings = *body->getRings();
|
||||
|
||||
double inner = 0.0, outer = 0.0;
|
||||
|
@ -1042,14 +1036,14 @@ static Body* CreateReferencePoint(const string& name,
|
|||
const string& path,
|
||||
Disposition disposition)
|
||||
{
|
||||
Body* body = NULL;
|
||||
Body* body = nullptr;
|
||||
|
||||
if (disposition == ModifyObject || disposition == ReplaceObject)
|
||||
{
|
||||
body = existingBody;
|
||||
}
|
||||
|
||||
if (body == NULL)
|
||||
if (body == nullptr)
|
||||
{
|
||||
body = new Body(system, name);
|
||||
// If the point doesn't exist, always treat the disposition as 'Add'
|
||||
|
@ -1067,7 +1061,7 @@ static Body* CreateReferencePoint(const string& name,
|
|||
// No valid timeline given; give up.
|
||||
if (body != existingBody)
|
||||
delete body;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Reference points can be marked visible; no geometry is shown, but the label and orbit
|
||||
|
@ -1144,7 +1138,7 @@ bool LoadSolarSystemObjects(istream& in,
|
|||
string parentName = tokenizer.getStringValue().c_str();
|
||||
|
||||
Value* objectDataValue = parser.readValue();
|
||||
if (objectDataValue == NULL)
|
||||
if (objectDataValue == nullptr)
|
||||
{
|
||||
sscError(tokenizer, "bad object definition");
|
||||
return false;
|
||||
|
@ -1158,8 +1152,8 @@ bool LoadSolarSystemObjects(istream& in,
|
|||
}
|
||||
Hash* objectData = objectDataValue->getHash();
|
||||
|
||||
Selection parent = universe.findPath(parentName, NULL, 0);
|
||||
PlanetarySystem* parentSystem = NULL;
|
||||
Selection parent = universe.findPath(parentName, nullptr, 0);
|
||||
PlanetarySystem* parentSystem = nullptr;
|
||||
|
||||
vector<string> names;
|
||||
// Iterate through the string for names delimited
|
||||
|
@ -1197,10 +1191,10 @@ bool LoadSolarSystemObjects(istream& in,
|
|||
if (bodyType != UnknownBodyType)
|
||||
{
|
||||
//bool orbitsPlanet = false;
|
||||
if (parent.star() != NULL)
|
||||
if (parent.star() != nullptr)
|
||||
{
|
||||
SolarSystem* solarSystem = universe.getSolarSystem(parent.star());
|
||||
if (solarSystem == NULL)
|
||||
if (solarSystem == nullptr)
|
||||
{
|
||||
// No solar system defined for this star yet, so we need
|
||||
// to create it.
|
||||
|
@ -1208,11 +1202,11 @@ bool LoadSolarSystemObjects(istream& in,
|
|||
}
|
||||
parentSystem = solarSystem->getPlanets();
|
||||
}
|
||||
else if (parent.body() != NULL)
|
||||
else if (parent.body() != nullptr)
|
||||
{
|
||||
// Parent is a planet or moon
|
||||
parentSystem = parent.body()->getSatellites();
|
||||
if (parentSystem == NULL)
|
||||
if (parentSystem == nullptr)
|
||||
{
|
||||
// If the planet doesn't already have any satellites, we
|
||||
// have to create a new planetary system for it.
|
||||
|
@ -1227,7 +1221,7 @@ bool LoadSolarSystemObjects(istream& in,
|
|||
cerr << _("parent body '") << parentName << _("' of '") << primaryName << _("' not found.") << endl;
|
||||
}
|
||||
|
||||
if (parentSystem != NULL)
|
||||
if (parentSystem != nullptr)
|
||||
{
|
||||
Body* existingBody = parentSystem->find(primaryName);
|
||||
if (existingBody)
|
||||
|
@ -1250,7 +1244,7 @@ bool LoadSolarSystemObjects(istream& in,
|
|||
else
|
||||
body = CreateBody(primaryName, parentSystem, universe, existingBody, objectData, directory, disposition, bodyType);
|
||||
|
||||
if (body != NULL && disposition == AddObject)
|
||||
if (body != nullptr && disposition == AddObject)
|
||||
{
|
||||
vector<string>::const_iterator iter = names.begin();
|
||||
iter++;
|
||||
|
@ -1268,17 +1262,17 @@ bool LoadSolarSystemObjects(istream& in,
|
|||
surface->color = Color(1.0f, 1.0f, 1.0f);
|
||||
surface->hazeColor = Color(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
FillinSurface(objectData, surface, directory);
|
||||
if (parent.body() != NULL)
|
||||
if (parent.body() != nullptr)
|
||||
parent.body()->addAlternateSurface(primaryName, surface);
|
||||
else
|
||||
sscError(tokenizer, _("bad alternate surface"));
|
||||
}
|
||||
else if (itemType == "Location")
|
||||
{
|
||||
if (parent.body() != NULL)
|
||||
if (parent.body() != nullptr)
|
||||
{
|
||||
Location* location = CreateLocation(objectData, parent.body());
|
||||
if (location != NULL)
|
||||
if (location != nullptr)
|
||||
{
|
||||
location->setName(primaryName);
|
||||
parent.body()->addLocation(location);
|
||||
|
@ -1304,8 +1298,8 @@ bool LoadSolarSystemObjects(istream& in,
|
|||
|
||||
SolarSystem::SolarSystem(Star* _star) :
|
||||
star(_star),
|
||||
planets(NULL),
|
||||
frameTree(NULL)
|
||||
planets(nullptr),
|
||||
frameTree(nullptr)
|
||||
{
|
||||
planets = new PlanetarySystem(star);
|
||||
frameTree = new FrameTree(star);
|
||||
|
|
|
@ -21,14 +21,12 @@
|
|||
using namespace Eigen;
|
||||
|
||||
|
||||
SphereMesh::SphereMesh(float radius, int _nRings, int _nSlices) :
|
||||
vertices(NULL), normals(NULL), texCoords(NULL), indices(NULL)
|
||||
SphereMesh::SphereMesh(float radius, int _nRings, int _nSlices)
|
||||
{
|
||||
createSphere(radius, _nRings, _nSlices);
|
||||
}
|
||||
|
||||
SphereMesh::SphereMesh(const Vector3f& size, int _nRings, int _nSlices) :
|
||||
vertices(NULL), normals(NULL), texCoords(NULL), indices(NULL)
|
||||
SphereMesh::SphereMesh(const Vector3f& size, int _nRings, int _nSlices)
|
||||
{
|
||||
createSphere(1.0f, _nRings, _nSlices);
|
||||
scale(size);
|
||||
|
@ -36,8 +34,7 @@ SphereMesh::SphereMesh(const Vector3f& size, int _nRings, int _nSlices) :
|
|||
|
||||
SphereMesh::SphereMesh(const Vector3f& size,
|
||||
const DisplacementMap& dispmap,
|
||||
float height) :
|
||||
vertices(NULL), normals(NULL), texCoords(NULL), indices(NULL)
|
||||
float height)
|
||||
{
|
||||
createSphere(1.0f, dispmap.getHeight(), dispmap.getWidth());
|
||||
scale(size);
|
||||
|
@ -60,16 +57,11 @@ SphereMesh::SphereMesh(const Vector3f& size,
|
|||
|
||||
SphereMesh::~SphereMesh()
|
||||
{
|
||||
if (vertices != NULL)
|
||||
delete[] vertices;
|
||||
if (normals != NULL)
|
||||
delete[] normals;
|
||||
if (texCoords != NULL)
|
||||
delete[] texCoords;
|
||||
if (indices != NULL)
|
||||
delete[] indices;
|
||||
if (tangents != NULL)
|
||||
delete[] tangents;
|
||||
delete[] vertices;
|
||||
delete[] normals;
|
||||
delete[] texCoords;
|
||||
delete[] indices;
|
||||
delete[] tangents;
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,9 +85,9 @@ void SphereMesh::createSphere(float radius, int _nRings, int _nSlices)
|
|||
{
|
||||
float theta = (float) j / (float) nSlices * (float) PI * 2;
|
||||
int n = i * (nSlices + 1) + j;
|
||||
float x = (float) (cos(phi) * cos(theta));
|
||||
float y = (float) sin(phi);
|
||||
float z = (float) (cos(phi) * sin(theta));
|
||||
auto x = (float) (std::cos(phi) * std::cos(theta));
|
||||
auto y = (float) std::sin(phi);
|
||||
auto z = (float) (std::cos(phi) * std::sin(theta));
|
||||
vertices[n * 3] = x * radius;
|
||||
vertices[n * 3 + 1] = y * radius;
|
||||
vertices[n * 3 + 2] = z * radius;
|
||||
|
@ -106,9 +98,9 @@ void SphereMesh::createSphere(float radius, int _nRings, int _nSlices)
|
|||
texCoords[n * 2 + 1] = 1.0f - (float) i / (float) (nRings - 1);
|
||||
|
||||
// Compute the tangent--required for bump mapping
|
||||
float tx = (float) (sin(phi) * sin(theta));
|
||||
float ty = (float) -cos(phi);
|
||||
float tz = (float) (sin(phi) * cos(theta));
|
||||
auto tx = (float) (std::sin(phi) * std::sin(theta));
|
||||
auto ty = (float) -std::cos(phi);
|
||||
auto tz = (float) (std::sin(phi) * std::cos(theta));
|
||||
tangents[n * 3] = tx;
|
||||
tangents[n * 3 + 1] = ty;
|
||||
tangents[n * 3 + 2] = tz;
|
||||
|
@ -169,7 +161,7 @@ void SphereMesh::generateNormals()
|
|||
}
|
||||
}
|
||||
|
||||
int* faceCounts = new int[nVertices];
|
||||
auto* faceCounts = new int[nVertices];
|
||||
for (i = 0; i < nVertices; i++)
|
||||
{
|
||||
faceCounts[i] = 0;
|
||||
|
@ -237,7 +229,7 @@ void SphereMesh::generateNormals()
|
|||
float nx = normals[i * 3] * s;
|
||||
float ny = normals[i * 3 + 1] * s;
|
||||
float nz = normals[i * 3 + 2] * s;
|
||||
float length = (float) sqrt(nx * nx + ny * ny + nz * nz);
|
||||
auto length = (float) std::sqrt(nx * nx + ny * ny + nz * nz);
|
||||
if (length > 0)
|
||||
{
|
||||
length = 1 / length;
|
||||
|
@ -285,7 +277,7 @@ void SphereMesh::scale(const Vector3f& s)
|
|||
}
|
||||
|
||||
// Modify the normals
|
||||
if (normals != NULL)
|
||||
if (normals != nullptr)
|
||||
{
|
||||
// TODO: Make a fast special case for uniform scale factors, where
|
||||
// renormalization is not required.
|
||||
|
@ -365,7 +357,7 @@ Mesh* SphereMesh::convertToMesh() const
|
|||
|
||||
// Copy the vertex data from the separate position, normal, and texture coordinate
|
||||
// arrays into a single array.
|
||||
char* vertexData = new char[stride * nVertices];
|
||||
auto* vertexData = new char[stride * nVertices];
|
||||
|
||||
int i;
|
||||
for (i = 0; i < nVertices; i++)
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
Mesh* convertToMesh() const;
|
||||
|
||||
private:
|
||||
void createSphere(float radius, int nRings, int nSlices);
|
||||
void createSphere(float radius, int _nRings, int _nSlices);
|
||||
void generateNormals();
|
||||
void scale(const Eigen::Vector3f&);
|
||||
void fixNormals();
|
||||
|
@ -54,12 +54,12 @@ public:
|
|||
int nRings;
|
||||
int nSlices;
|
||||
int nVertices;
|
||||
float* vertices;
|
||||
float* normals;
|
||||
float* texCoords;
|
||||
float* tangents;
|
||||
float* vertices{ nullptr };
|
||||
float* normals{ nullptr };
|
||||
float* texCoords{ nullptr };
|
||||
float* tangents{ nullptr };
|
||||
int nIndices;
|
||||
unsigned short* indices;
|
||||
unsigned short* indices{ nullptr };
|
||||
};
|
||||
|
||||
#endif // _CELENGINE_SPHEREMESH_H_
|
||||
|
|
|
@ -43,11 +43,11 @@ struct SpectralTypeInfo
|
|||
};
|
||||
|
||||
|
||||
static StarDetails** normalStarDetails = NULL;
|
||||
static StarDetails** whiteDwarfDetails = NULL;
|
||||
static StarDetails* neutronStarDetails = NULL;
|
||||
static StarDetails* blackHoleDetails = NULL;
|
||||
static StarDetails* barycenterDetails = NULL;
|
||||
static StarDetails** normalStarDetails = nullptr;
|
||||
static StarDetails** whiteDwarfDetails = nullptr;
|
||||
static StarDetails* neutronStarDetails = nullptr;
|
||||
static StarDetails* blackHoleDetails = nullptr;
|
||||
static StarDetails* barycenterDetails = nullptr;
|
||||
|
||||
static string DEFAULT_INFO_URL("");
|
||||
|
||||
|
@ -398,7 +398,7 @@ StarDetails::GetStarDetails(const StellarClass& sc)
|
|||
case StellarClass::BlackHole:
|
||||
return GetBlackHoleDetails();
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -409,7 +409,7 @@ StarDetails::CreateStandardStarType(const std::string& specTypeName,
|
|||
float _rotationPeriod)
|
||||
|
||||
{
|
||||
StarDetails* details = new StarDetails();
|
||||
auto* details = new StarDetails();
|
||||
|
||||
details->setTemperature(_temperature);
|
||||
details->setSpectralType(specTypeName);
|
||||
|
@ -429,20 +429,20 @@ StarDetails::GetNormalStarDetails(StellarClass::SpectralClass specClass,
|
|||
unsigned int subclass,
|
||||
StellarClass::LuminosityClass lumClass)
|
||||
{
|
||||
if (normalStarDetails == NULL)
|
||||
if (normalStarDetails == nullptr)
|
||||
{
|
||||
unsigned int nTypes = StellarClass::Spectral_Count * 11 *
|
||||
StellarClass::Lum_Count;
|
||||
normalStarDetails = new StarDetails*[nTypes];
|
||||
for (unsigned int i = 0; i < nTypes; i++)
|
||||
normalStarDetails[i] = NULL;
|
||||
normalStarDetails[i] = nullptr;
|
||||
}
|
||||
|
||||
if (subclass > StellarClass::Subclass_Unknown)
|
||||
subclass = StellarClass::Subclass_Unknown;
|
||||
|
||||
uint index = subclass + (specClass + lumClass * StellarClass::Spectral_Count) * 11;
|
||||
if (normalStarDetails[index] == NULL)
|
||||
if (normalStarDetails[index] == nullptr)
|
||||
{
|
||||
char name[16];
|
||||
if ((lumClass == StellarClass::Lum_VI) &&
|
||||
|
@ -641,20 +641,20 @@ StarDetails::GetWhiteDwarfDetails(StellarClass::SpectralClass specClass,
|
|||
unsigned int scIndex = static_cast<unsigned int>(specClass) -
|
||||
StellarClass::FirstWDClass;
|
||||
|
||||
if (whiteDwarfDetails == NULL)
|
||||
if (whiteDwarfDetails == nullptr)
|
||||
{
|
||||
unsigned int nTypes =
|
||||
StellarClass::WDClassCount * StellarClass::SubclassCount;
|
||||
whiteDwarfDetails = new StarDetails*[nTypes];
|
||||
for (unsigned int i = 0; i < nTypes; i++)
|
||||
whiteDwarfDetails[i] = NULL;
|
||||
whiteDwarfDetails[i] = nullptr;
|
||||
}
|
||||
|
||||
if (subclass > StellarClass::Subclass_Unknown)
|
||||
subclass = StellarClass::Subclass_Unknown;
|
||||
|
||||
uint index = subclass + (scIndex * StellarClass::SubclassCount);
|
||||
if (whiteDwarfDetails[index] == NULL)
|
||||
if (whiteDwarfDetails[index] == nullptr)
|
||||
{
|
||||
char name[16];
|
||||
sprintf(name, "%s%s",
|
||||
|
@ -695,7 +695,7 @@ StarDetails::GetWhiteDwarfDetails(StellarClass::SpectralClass specClass,
|
|||
StarDetails*
|
||||
StarDetails::GetNeutronStarDetails()
|
||||
{
|
||||
if (neutronStarDetails == NULL)
|
||||
if (neutronStarDetails == nullptr)
|
||||
{
|
||||
// The default neutron star has a rotation period of one second,
|
||||
// surface temperature of five million K.
|
||||
|
@ -716,7 +716,7 @@ StarDetails::GetNeutronStarDetails()
|
|||
StarDetails*
|
||||
StarDetails::GetBlackHoleDetails()
|
||||
{
|
||||
if (blackHoleDetails == NULL)
|
||||
if (blackHoleDetails == nullptr)
|
||||
{
|
||||
// Default black hole parameters are based on a one solar mass
|
||||
// black hole.
|
||||
|
@ -736,7 +736,7 @@ StarDetails*
|
|||
StarDetails::GetBarycenterDetails()
|
||||
{
|
||||
|
||||
if (barycenterDetails == NULL)
|
||||
if (barycenterDetails == nullptr)
|
||||
{
|
||||
barycenterDetails = CreateStandardStarType("Bary", 1.0f, 1.0f);
|
||||
barycenterDetails->setRadius(0.001f);
|
||||
|
@ -756,21 +756,7 @@ StarDetails::SetStarTextures(const StarTextureSet& _starTextures)
|
|||
|
||||
|
||||
StarDetails::StarDetails() :
|
||||
radius(0.0f),
|
||||
temperature(0.0f),
|
||||
bolometricCorrection(0.0f),
|
||||
knowledge(0u),
|
||||
visible(true),
|
||||
texture(texture), // warning: ‘StarDetails::texture’ is initialized with itself [-Winit-self]
|
||||
geometry(InvalidResource),
|
||||
orbit(NULL),
|
||||
orbitalRadius(0.0f),
|
||||
barycenter(NULL),
|
||||
rotationModel(NULL),
|
||||
semiAxes(1.0f, 1.0f, 1.0f),
|
||||
infoURL(NULL),
|
||||
orbitingStars(NULL),
|
||||
isShared(true)
|
||||
texture(texture) // warning: ‘StarDetails::texture’ is initialized with itself [-Winit-self]
|
||||
{
|
||||
spectralType[0] = '\0';
|
||||
}
|
||||
|
@ -789,13 +775,13 @@ StarDetails::StarDetails(const StarDetails& sd) :
|
|||
barycenter(sd.barycenter),
|
||||
rotationModel(sd.rotationModel),
|
||||
semiAxes(sd.semiAxes),
|
||||
infoURL(NULL),
|
||||
orbitingStars(NULL),
|
||||
infoURL(nullptr),
|
||||
orbitingStars(nullptr),
|
||||
isShared(false)
|
||||
{
|
||||
assert(sd.isShared);
|
||||
memcpy(spectralType, sd.spectralType, sizeof(spectralType));
|
||||
if (sd.infoURL != NULL)
|
||||
if (sd.infoURL != nullptr)
|
||||
infoURL = new string(*sd.infoURL);
|
||||
}
|
||||
|
||||
|
@ -813,10 +799,7 @@ StarDetails::~StarDetails()
|
|||
const std::string&
|
||||
StarDetails::getInfoURL() const
|
||||
{
|
||||
if (infoURL != NULL)
|
||||
return *infoURL;
|
||||
else
|
||||
return DEFAULT_INFO_URL;
|
||||
return infoURL ? *infoURL : DEFAULT_INFO_URL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -896,7 +879,7 @@ StarDetails::setOrbitBarycenter(Star* bc)
|
|||
void
|
||||
StarDetails::setOrbitalRadius(float r)
|
||||
{
|
||||
if (orbit != NULL)
|
||||
if (orbit != nullptr)
|
||||
orbitalRadius = r;
|
||||
}
|
||||
|
||||
|
@ -904,14 +887,14 @@ StarDetails::setOrbitalRadius(float r)
|
|||
void
|
||||
StarDetails::computeOrbitalRadius()
|
||||
{
|
||||
if (orbit == NULL)
|
||||
if (orbit == nullptr)
|
||||
{
|
||||
orbitalRadius = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
orbitalRadius = (float) astro::kilometersToLightYears(orbit->getBoundingRadius());
|
||||
if (barycenter != NULL)
|
||||
if (barycenter != nullptr)
|
||||
orbitalRadius += barycenter->getOrbitalRadius();
|
||||
}
|
||||
}
|
||||
|
@ -941,7 +924,7 @@ StarDetails::setInfoURL(const string& _infoURL)
|
|||
// Save space in the common case--no InfoURL--by not
|
||||
// allocating a string.
|
||||
delete infoURL;
|
||||
infoURL = NULL;
|
||||
infoURL = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -982,7 +965,7 @@ float Star::getRadius() const
|
|||
// visual magnitude of the star.
|
||||
float solarBMag = SOLAR_BOLOMETRIC_MAG;
|
||||
float bmag = getBolometricMagnitude();
|
||||
float boloLum = (float) exp((solarBMag - bmag) / LN_MAG);
|
||||
auto boloLum = (float) exp((solarBMag - bmag) / LN_MAG);
|
||||
|
||||
// Use the Stefan-Boltzmann law to estimate the radius of a
|
||||
// star from surface temperature and luminosity
|
||||
|
@ -1010,7 +993,7 @@ void
|
|||
StarDetails::addOrbitingStar(Star* star)
|
||||
{
|
||||
assert(!shared());
|
||||
if (orbitingStars == NULL)
|
||||
if (orbitingStars == nullptr)
|
||||
orbitingStars = new vector<Star*>();
|
||||
orbitingStars->push_back(star);
|
||||
}
|
||||
|
@ -1022,7 +1005,7 @@ UniversalCoord
|
|||
Star::getPosition(double t) const
|
||||
{
|
||||
const Orbit* orbit = getOrbit();
|
||||
if (!orbit)
|
||||
if (orbit == nullptr)
|
||||
{
|
||||
return UniversalCoord::CreateLy(position.cast<double>());
|
||||
}
|
||||
|
@ -1030,7 +1013,7 @@ Star::getPosition(double t) const
|
|||
{
|
||||
const Star* barycenter = getOrbitBarycenter();
|
||||
|
||||
if (barycenter == NULL)
|
||||
if (barycenter == nullptr)
|
||||
{
|
||||
UniversalCoord barycenterPos = UniversalCoord::CreateLy(position.cast<double>());
|
||||
return UniversalCoord(barycenterPos).offsetKm(orbit->positionAtTime(t));
|
||||
|
@ -1048,7 +1031,7 @@ Star::getOrbitBarycenterPosition(double t) const
|
|||
{
|
||||
const Star* barycenter = getOrbitBarycenter();
|
||||
|
||||
if (barycenter == NULL)
|
||||
if (barycenter == nullptr)
|
||||
{
|
||||
return UniversalCoord::CreateLy(position.cast<double>());
|
||||
}
|
||||
|
@ -1065,7 +1048,7 @@ Vector3d
|
|||
Star::getVelocity(double t) const
|
||||
{
|
||||
const Orbit* orbit = getOrbit();
|
||||
if (!orbit)
|
||||
if (orbit == nullptr)
|
||||
{
|
||||
// The star doesn't have a defined orbit, so the velocity is just
|
||||
// zero. (This will change when stellar proper motion is implemented.)
|
||||
|
@ -1075,7 +1058,7 @@ Star::getVelocity(double t) const
|
|||
{
|
||||
const Star* barycenter = getOrbitBarycenter();
|
||||
|
||||
if (barycenter == NULL)
|
||||
if (barycenter == nullptr)
|
||||
{
|
||||
// Star orbit is defined around a fixed point, so the total velocity
|
||||
// is just the star's orbit velocity.
|
||||
|
|
|
@ -86,29 +86,29 @@ class StarDetails
|
|||
void addOrbitingStar(Star*);
|
||||
|
||||
private:
|
||||
float radius;
|
||||
float temperature;
|
||||
float bolometricCorrection;
|
||||
float radius{ 0.0f };
|
||||
float temperature{ 0.0f };
|
||||
float bolometricCorrection{ 0.0f };
|
||||
|
||||
uint32 knowledge;
|
||||
bool visible;
|
||||
uint32 knowledge{ 0 };
|
||||
bool visible{ true };
|
||||
char spectralType[8];
|
||||
|
||||
MultiResTexture texture;
|
||||
ResourceHandle geometry;
|
||||
ResourceHandle geometry{ InvalidResource };
|
||||
|
||||
Orbit* orbit;
|
||||
float orbitalRadius;
|
||||
Star* barycenter;
|
||||
Orbit* orbit{ nullptr };
|
||||
float orbitalRadius{ 0.0f };
|
||||
Star* barycenter{ nullptr };
|
||||
|
||||
const RotationModel* rotationModel;
|
||||
const RotationModel* rotationModel{ nullptr };
|
||||
|
||||
Eigen::Vector3f semiAxes;
|
||||
Eigen::Vector3f semiAxes{ 1.0f, 1.0f, 1.0f };
|
||||
|
||||
std::string* infoURL;
|
||||
std::string* infoURL{ nullptr };
|
||||
|
||||
std::vector<Star*>* orbitingStars;
|
||||
bool isShared;
|
||||
std::vector<Star*>* orbitingStars{ nullptr };
|
||||
bool isShared{ true };
|
||||
|
||||
public:
|
||||
struct StarTextureSet
|
||||
|
@ -120,7 +120,7 @@ class StarDetails
|
|||
|
||||
public:
|
||||
static StarDetails* GetStarDetails(const StellarClass&);
|
||||
static StarDetails* CreateStandardStarType(const std::string& _specType,
|
||||
static StarDetails* CreateStandardStarType(const std::string& specTypeName,
|
||||
float _temperature,
|
||||
float _rotationPeriod);
|
||||
|
||||
|
@ -310,7 +310,7 @@ Star::Star() :
|
|||
catalogNumber(InvalidCatalogNumber),
|
||||
position(0, 0, 0),
|
||||
absMag(4.83f),
|
||||
details(NULL)
|
||||
details(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -140,11 +140,8 @@ findStars(const StarDatabase& stardb, Pred pred, int nStars)
|
|||
|
||||
// Move the best matching stars into the vector
|
||||
finalStars->reserve(nStars);
|
||||
for (typename StarSet::const_iterator iter = firstStars.begin();
|
||||
iter != firstStars.end(); iter++)
|
||||
{
|
||||
finalStars->insert(finalStars->end(), *iter);
|
||||
}
|
||||
for (const auto& star : firstStars)
|
||||
finalStars->insert(finalStars->end(), star);
|
||||
|
||||
return finalStars;
|
||||
}
|
||||
|
@ -187,8 +184,8 @@ StarBrowser::listStars(unsigned int nStars)
|
|||
case StarsWithPlanets:
|
||||
{
|
||||
SolarSystemCatalog* solarSystems = univ->getSolarSystemCatalog();
|
||||
if (solarSystems == NULL)
|
||||
return NULL;
|
||||
if (!solarSystems)
|
||||
return nullptr;
|
||||
SolarSystemPredicate solarSysPred;
|
||||
solarSysPred.pos = pos;
|
||||
solarSysPred.solarSystems = solarSystems;
|
||||
|
@ -207,7 +204,7 @@ StarBrowser::listStars(unsigned int nStars)
|
|||
break;
|
||||
}
|
||||
|
||||
return NULL; // keep compiler happy
|
||||
return nullptr; // keep compiler happy
|
||||
}
|
||||
|
||||
|
||||
|
@ -247,7 +244,7 @@ StarBrowser::StarBrowser(Simulation* _appSim, int pred) :
|
|||
StarBrowser::StarBrowser() :
|
||||
pos(Vector3f::Zero()),
|
||||
ucPos(UniversalCoord::Zero()),
|
||||
appSim(NULL),
|
||||
appSim(nullptr),
|
||||
predicate(NearestStars)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -470,8 +470,8 @@ Color StarColors_Blackbody_2deg_D65[401] =
|
|||
};
|
||||
|
||||
|
||||
static ColorTemperatureTable* enhanced = NULL;
|
||||
static ColorTemperatureTable* blackbodyD65 = NULL;
|
||||
static ColorTemperatureTable* enhanced = nullptr;
|
||||
static ColorTemperatureTable* blackbodyD65 = nullptr;
|
||||
|
||||
ColorTemperatureTable*
|
||||
GetStarColorTable(ColorTableType ct)
|
||||
|
@ -479,7 +479,7 @@ GetStarColorTable(ColorTableType ct)
|
|||
switch (ct)
|
||||
{
|
||||
case ColorTable_Enhanced:
|
||||
if (enhanced == NULL)
|
||||
if (enhanced == nullptr)
|
||||
{
|
||||
enhanced = new ColorTemperatureTable(StarColors_Enhanced,
|
||||
41, 40000.0f);
|
||||
|
@ -487,7 +487,7 @@ GetStarColorTable(ColorTableType ct)
|
|||
return enhanced;
|
||||
|
||||
case ColorTable_Blackbody_D65:
|
||||
if (blackbodyD65 == NULL)
|
||||
if (blackbodyD65 == nullptr)
|
||||
{
|
||||
blackbodyD65 = new ColorTemperatureTable(StarColors_Blackbody_2deg_D65,
|
||||
401, 40000.0f);
|
||||
|
@ -495,6 +495,6 @@ GetStarColorTable(ColorTableType ct)
|
|||
return blackbodyD65;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ struct CatalogNumberOrderingPredicate
|
|||
{
|
||||
int unused;
|
||||
|
||||
CatalogNumberOrderingPredicate() {};
|
||||
CatalogNumberOrderingPredicate() = default;
|
||||
|
||||
bool operator()(const Star& star0, const Star& star1) const
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ struct CatalogNumberEquivalencePredicate
|
|||
{
|
||||
int unused;
|
||||
|
||||
CatalogNumberEquivalencePredicate() {};
|
||||
CatalogNumberEquivalencePredicate() = default;
|
||||
|
||||
bool operator()(const Star& star0, const Star& star1) const
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ struct PtrCatalogNumberOrderingPredicate
|
|||
{
|
||||
int unused;
|
||||
|
||||
PtrCatalogNumberOrderingPredicate() {};
|
||||
PtrCatalogNumberOrderingPredicate() = default;
|
||||
|
||||
bool operator()(const Star* const & star0, const Star* const & star1) const
|
||||
{
|
||||
|
@ -179,14 +179,7 @@ bool StarDatabase::CrossIndexEntry::operator<(const StarDatabase::CrossIndexEntr
|
|||
}
|
||||
|
||||
|
||||
StarDatabase::StarDatabase():
|
||||
nStars (0),
|
||||
stars (NULL),
|
||||
namesDB (NULL),
|
||||
octreeRoot (NULL),
|
||||
nextAutoCatalogNumber(0xfffffffe),
|
||||
binFileCatalogNumberIndex(NULL),
|
||||
binFileStarCount(0)
|
||||
StarDatabase::StarDatabase()
|
||||
{
|
||||
crossIndexes.resize(MaxCatalog);
|
||||
}
|
||||
|
@ -194,17 +187,11 @@ StarDatabase::StarDatabase():
|
|||
|
||||
StarDatabase::~StarDatabase()
|
||||
{
|
||||
if (stars != NULL)
|
||||
delete [] stars;
|
||||
delete [] stars;
|
||||
delete [] catalogNumberIndex;
|
||||
|
||||
if (catalogNumberIndex != NULL)
|
||||
delete [] catalogNumberIndex;
|
||||
|
||||
for (vector<CrossIndex*>::iterator iter = crossIndexes.begin(); iter != crossIndexes.end(); ++iter)
|
||||
{
|
||||
if (*iter != NULL)
|
||||
delete *iter;
|
||||
}
|
||||
for (const auto index : crossIndexes)
|
||||
delete index;
|
||||
}
|
||||
|
||||
|
||||
|
@ -221,7 +208,7 @@ Star* StarDatabase::find(uint32 catalogNumber) const
|
|||
if (star != catalogNumberIndex + nStars && (*star)->getCatalogNumber() == catalogNumber)
|
||||
return *star;
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -232,7 +219,7 @@ uint32 StarDatabase::findCatalogNumberByName(const string& name) const
|
|||
|
||||
uint32 catalogNumber = Star::InvalidCatalogNumber;
|
||||
|
||||
if (namesDB != NULL)
|
||||
if (namesDB != nullptr)
|
||||
{
|
||||
catalogNumber = namesDB->findCatalogNumberByName(name);
|
||||
if (catalogNumber != Star::InvalidCatalogNumber)
|
||||
|
@ -273,7 +260,7 @@ Star* StarDatabase::find(const string& name) const
|
|||
if (catalogNumber != Star::InvalidCatalogNumber)
|
||||
return find(catalogNumber);
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -283,16 +270,15 @@ uint32 StarDatabase::crossIndex(const Catalog catalog, const uint32 celCatalogNu
|
|||
return Star::InvalidCatalogNumber;
|
||||
|
||||
CrossIndex* xindex = crossIndexes[catalog];
|
||||
if (xindex == NULL)
|
||||
if (xindex == nullptr)
|
||||
return Star::InvalidCatalogNumber;
|
||||
|
||||
// A simple linear search. We could store cross indices sorted by
|
||||
// both catalog numbers and trade memory for speed
|
||||
for (CrossIndex::const_iterator iter = xindex->begin(); iter != xindex->end(); iter++)
|
||||
{
|
||||
if (celCatalogNumber == iter->celCatalogNumber)
|
||||
return iter->catalogNumber;
|
||||
}
|
||||
auto iter = std::find_if(xindex->begin(), xindex->end(),
|
||||
[celCatalogNumber](auto& o){ return celCatalogNumber == o.celCatalogNumber; });
|
||||
if (iter != xindex->end())
|
||||
return iter->catalogNumber;
|
||||
|
||||
return Star::InvalidCatalogNumber;
|
||||
}
|
||||
|
@ -306,7 +292,7 @@ uint32 StarDatabase::searchCrossIndexForCatalogNumber(const Catalog catalog, con
|
|||
return Star::InvalidCatalogNumber;
|
||||
|
||||
CrossIndex* xindex = crossIndexes[catalog];
|
||||
if (xindex == NULL)
|
||||
if (xindex == nullptr)
|
||||
return Star::InvalidCatalogNumber;
|
||||
|
||||
CrossIndexEntry xindexEnt;
|
||||
|
@ -327,7 +313,7 @@ Star* StarDatabase::searchCrossIndex(const Catalog catalog, const uint32 number)
|
|||
if (celCatalogNumber != Star::InvalidCatalogNumber)
|
||||
return find(celCatalogNumber);
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -336,7 +322,7 @@ vector<string> StarDatabase::getCompletion(const string& name) const
|
|||
vector<string> completion;
|
||||
|
||||
// only named stars are supported by completion.
|
||||
if (!name.empty() && namesDB != NULL)
|
||||
if (!name.empty() && namesDB != nullptr)
|
||||
return namesDB->getCompletion(name);
|
||||
else
|
||||
return completion;
|
||||
|
@ -384,7 +370,7 @@ string StarDatabase::getStarName(const Star& star, bool i18n) const
|
|||
{
|
||||
uint32 catalogNumber = star.getCatalogNumber();
|
||||
|
||||
if (namesDB != NULL)
|
||||
if (namesDB != nullptr)
|
||||
{
|
||||
StarNameDatabase::NumberIndex::const_iterator iter = namesDB->getFirstNameIter(catalogNumber);
|
||||
if (iter != namesDB->getFinalNameIter() && iter->first == catalogNumber)
|
||||
|
@ -417,7 +403,7 @@ void StarDatabase::getStarName(const Star& star, char* nameBuffer, unsigned int
|
|||
|
||||
uint32 catalogNumber = star.getCatalogNumber();
|
||||
|
||||
if (namesDB != NULL)
|
||||
if (namesDB != nullptr)
|
||||
{
|
||||
StarNameDatabase::NumberIndex::const_iterator iter = namesDB->getFirstNameIter(catalogNumber);
|
||||
if (iter != namesDB->getFinalNameIter() && iter->first == catalogNumber)
|
||||
|
@ -441,9 +427,9 @@ string StarDatabase::getStarNameList(const Star& star, const unsigned int maxNam
|
|||
string starNames;
|
||||
char numString[32];
|
||||
|
||||
unsigned int catalogNumber = star.getCatalogNumber();
|
||||
unsigned int catalogNumber = star.getCatalogNumber();
|
||||
|
||||
StarNameDatabase::NumberIndex::const_iterator iter = namesDB->getFirstNameIter(catalogNumber);
|
||||
StarNameDatabase::NumberIndex::const_iterator iter = namesDB->getFirstNameIter(catalogNumber);
|
||||
|
||||
unsigned int count = 0;
|
||||
while (iter != namesDB->getFinalNameIter() && iter->first == catalogNumber && count < maxNames)
|
||||
|
@ -567,7 +553,7 @@ bool StarDatabase::loadCrossIndex(const Catalog catalog, istream& in)
|
|||
if (static_cast<unsigned int>(catalog) >= crossIndexes.size())
|
||||
return false;
|
||||
|
||||
if (crossIndexes[catalog] != NULL)
|
||||
if (crossIndexes[catalog] != nullptr)
|
||||
delete crossIndexes[catalog];
|
||||
|
||||
// Verify that the star database file has a correct header
|
||||
|
@ -597,7 +583,7 @@ bool StarDatabase::loadCrossIndex(const Catalog catalog, istream& in)
|
|||
}
|
||||
|
||||
CrossIndex* xindex = new CrossIndex();
|
||||
if (xindex == NULL)
|
||||
if (xindex == nullptr)
|
||||
return false;
|
||||
|
||||
unsigned int record = 0;
|
||||
|
@ -690,12 +676,12 @@ bool StarDatabase::loadBinary(istream& in)
|
|||
star.setPosition(x, y, z);
|
||||
star.setAbsoluteMagnitude((float) absMag / 256.0f);
|
||||
|
||||
StarDetails* details = NULL;
|
||||
StarDetails* details = nullptr;
|
||||
StellarClass sc;
|
||||
if (sc.unpack(spectralType))
|
||||
details = StarDetails::GetStarDetails(sc);
|
||||
|
||||
if (details == NULL)
|
||||
if (details == nullptr)
|
||||
{
|
||||
cerr << _("Bad spectral type in star database, star #") << nStars << "\n";
|
||||
return false;
|
||||
|
@ -750,14 +736,13 @@ void StarDatabase::finish()
|
|||
// the barycenters have been resolved, and these are required when building
|
||||
// the octree. This will only rarely cause a problem, but it still needs
|
||||
// to be addressed.
|
||||
for (vector<BarycenterUsage>::const_iterator iter = barycenters.begin();
|
||||
iter != barycenters.end(); iter++)
|
||||
for (const auto& b : barycenters)
|
||||
{
|
||||
Star* star = find(iter->catNo);
|
||||
Star* barycenter = find(iter->barycenterCatNo);
|
||||
assert(star != NULL);
|
||||
assert(barycenter != NULL);
|
||||
if (star != NULL && barycenter != NULL)
|
||||
Star* star = find(b.catNo);
|
||||
Star* barycenter = find(b.barycenterCatNo);
|
||||
assert(star != nullptr);
|
||||
assert(barycenter != nullptr);
|
||||
if (star != nullptr && barycenter != nullptr)
|
||||
{
|
||||
star->setOrbitBarycenter(barycenter);
|
||||
barycenter->addOrbitingStar(star);
|
||||
|
@ -790,7 +775,7 @@ bool StarDatabase::createStar(Star* star,
|
|||
const string& path,
|
||||
bool isBarycenter)
|
||||
{
|
||||
StarDetails* details = NULL;
|
||||
StarDetails* details = nullptr;
|
||||
string spectralType;
|
||||
|
||||
// Get the magnitude and spectral type; if the star is actually
|
||||
|
@ -805,7 +790,7 @@ bool StarDatabase::createStar(Star* star,
|
|||
{
|
||||
StellarClass sc = StellarClass::parse(spectralType);
|
||||
details = StarDetails::GetStarDetails(sc);
|
||||
if (details == NULL)
|
||||
if (details == nullptr)
|
||||
{
|
||||
cerr << _("Invalid star: bad spectral type.\n");
|
||||
return false;
|
||||
|
@ -832,7 +817,7 @@ bool StarDatabase::createStar(Star* star,
|
|||
if (!existingDetails->shared())
|
||||
{
|
||||
modifyExistingDetails = true;
|
||||
if (details != NULL)
|
||||
if (details != nullptr)
|
||||
{
|
||||
// If the spectral type was modified, copy the new data
|
||||
// to the custom details record.
|
||||
|
@ -848,7 +833,7 @@ bool StarDatabase::createStar(Star* star,
|
|||
|
||||
details = existingDetails;
|
||||
}
|
||||
else if (details == NULL)
|
||||
else if (details == nullptr)
|
||||
{
|
||||
details = existingDetails;
|
||||
}
|
||||
|
@ -860,7 +845,7 @@ bool StarDatabase::createStar(Star* star,
|
|||
bool hasModel = starData->getString("Mesh", modelName);
|
||||
|
||||
RotationModel* rm = CreateRotationModel(starData, path, 1.0);
|
||||
bool hasRotationModel = (rm != NULL);
|
||||
bool hasRotationModel = (rm != nullptr);
|
||||
|
||||
Vector3d semiAxes = Vector3d::Ones();
|
||||
bool hasSemiAxes = starData->getLengthVector("SemiAxes", semiAxes);
|
||||
|
@ -888,7 +873,7 @@ bool StarDatabase::createStar(Star* star,
|
|||
|
||||
if (hasTexture ||
|
||||
hasModel ||
|
||||
orbit != NULL ||
|
||||
orbit != nullptr ||
|
||||
hasSemiAxes ||
|
||||
hasRadius ||
|
||||
hasTemperature ||
|
||||
|
@ -959,7 +944,7 @@ bool StarDatabase::createStar(Star* star,
|
|||
details->setInfoURL(infoURL);
|
||||
}
|
||||
|
||||
if (orbit != NULL)
|
||||
if (orbit != nullptr)
|
||||
{
|
||||
details->setOrbit(orbit);
|
||||
|
||||
|
@ -994,7 +979,7 @@ bool StarDatabase::createStar(Star* star,
|
|||
// Even though we can't actually get the Star pointer for
|
||||
// the barycenter, we can get the star information.
|
||||
Star* barycenter = findWhileLoading(barycenterCatNo);
|
||||
if (barycenter != NULL)
|
||||
if (barycenter != nullptr)
|
||||
{
|
||||
hasBarycenter = true;
|
||||
barycenterPosition = barycenter->getPosition();
|
||||
|
@ -1255,7 +1240,7 @@ bool StarDatabase::load(istream& in, const string& resourcePath)
|
|||
}
|
||||
}
|
||||
|
||||
Star* star = NULL;
|
||||
Star* star = nullptr;
|
||||
|
||||
switch (disposition)
|
||||
{
|
||||
|
@ -1306,12 +1291,12 @@ bool StarDatabase::load(istream& in, const string& resourcePath)
|
|||
break;
|
||||
}
|
||||
|
||||
bool isNewStar = star == NULL;
|
||||
bool isNewStar = star == nullptr;
|
||||
|
||||
tokenizer.pushBack();
|
||||
|
||||
Value* starDataValue = parser.readValue();
|
||||
if (starDataValue == NULL)
|
||||
if (starDataValue == nullptr)
|
||||
{
|
||||
clog << "Error reading star." << endl;
|
||||
return false;
|
||||
|
@ -1351,7 +1336,7 @@ bool StarDatabase::load(istream& in, const string& resourcePath)
|
|||
stcFileCatalogNumberIndex[catalogNumber] = &unsortedStars[unsortedStars.size() - 1];
|
||||
}
|
||||
|
||||
if (namesDB != NULL && !objName.empty())
|
||||
if (namesDB != nullptr && !objName.empty())
|
||||
{
|
||||
// List of namesDB will replace any that already exist for
|
||||
// this star.
|
||||
|
@ -1393,7 +1378,7 @@ bool StarDatabase::load(istream& in, const string& resourcePath)
|
|||
void StarDatabase::buildOctree()
|
||||
{
|
||||
// This should only be called once for the database
|
||||
// ASSERT(octreeRoot == NULL);
|
||||
// ASSERT(octreeRoot == nullptr);
|
||||
|
||||
DPRINTF(1, "Sorting stars into octree . . .\n");
|
||||
float absMag = astro::appToAbsMag(STAR_OCTREE_MAGNITUDE,
|
||||
|
@ -1417,13 +1402,14 @@ void StarDatabase::buildOctree()
|
|||
#ifdef PROFILE_OCTREE
|
||||
vector<OctreeLevelStatistics> stats;
|
||||
octreeRoot->computeStatistics(stats);
|
||||
for (vector<OctreeLevelStatistics>::const_iterator iter = stats.begin(); iter != stats.end(); ++iter)
|
||||
int level = 0;
|
||||
for (const auto& stat : stats)
|
||||
{
|
||||
int level = iter - stats.begin();
|
||||
level++;
|
||||
clog << "Level " << level << ", "
|
||||
<< STAR_OCTREE_ROOT_SIZE / pow(2.0, (double) level) << "ly, "
|
||||
<< iter->nodeCount << " nodes, "
|
||||
<< iter->objectCount << " stars\n";
|
||||
<< stat.nodeCount << " nodes, "
|
||||
<< stat.objectCount << " stars\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1439,7 +1425,7 @@ void StarDatabase::buildOctree()
|
|||
void StarDatabase::buildIndexes()
|
||||
{
|
||||
// This should only be called once for the database
|
||||
// assert(catalogNumberIndexes[0] == NULL);
|
||||
// assert(catalogNumberIndexes[0] == nullptr);
|
||||
|
||||
DPRINTF(1, "Building catalog number indexes . . .\n");
|
||||
|
||||
|
@ -1465,7 +1451,7 @@ void StarDatabase::buildIndexes()
|
|||
Star* StarDatabase::findWhileLoading(uint32 catalogNumber) const
|
||||
{
|
||||
// First check for stars loaded from the binary database
|
||||
if (binFileCatalogNumberIndex != NULL)
|
||||
if (binFileCatalogNumberIndex != nullptr)
|
||||
{
|
||||
Star refStar;
|
||||
refStar.setCatalogNumber(catalogNumber);
|
||||
|
@ -1487,6 +1473,6 @@ Star* StarDatabase::findWhileLoading(uint32 catalogNumber) const
|
|||
}
|
||||
|
||||
// Star not found
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -190,13 +190,13 @@ private:
|
|||
void buildIndexes();
|
||||
Star* findWhileLoading(uint32 catalogNumber) const;
|
||||
|
||||
int nStars;
|
||||
int nStars{ 0 };
|
||||
|
||||
Star* stars;
|
||||
StarNameDatabase* namesDB;
|
||||
Star* stars{ nullptr };
|
||||
StarNameDatabase* namesDB{ nullptr };
|
||||
Star** catalogNumberIndex;
|
||||
StarOctree* octreeRoot;
|
||||
uint32 nextAutoCatalogNumber;
|
||||
StarOctree* octreeRoot{ nullptr };
|
||||
uint32 nextAutoCatalogNumber{ 0xfffffffe };
|
||||
|
||||
std::vector<CrossIndex*> crossIndexes;
|
||||
|
||||
|
@ -204,8 +204,8 @@ private:
|
|||
// not used after loading is complete.
|
||||
BlockArray<Star> unsortedStars;
|
||||
// List of stars loaded from binary file, sorted by catalog number
|
||||
Star** binFileCatalogNumberIndex;
|
||||
unsigned int binFileStarCount;
|
||||
Star** binFileCatalogNumberIndex{ nullptr };
|
||||
unsigned int binFileStarCount{ 0 };
|
||||
// Catalog number -> star mapping for stars loaded from stc files
|
||||
std::map<uint32, Star*> stcFileCatalogNumberIndex;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ uint32 StarNameDatabase::findCatalogNumberByName(const string& name) const
|
|||
string prefix(name, 0, pos);
|
||||
string conName(name, pos + 1, string::npos);
|
||||
Constellation* con = Constellation::getConstellation(conName);
|
||||
if (con != NULL)
|
||||
if (con != nullptr)
|
||||
{
|
||||
char digit = ' ';
|
||||
int len = prefix.length();
|
||||
|
@ -144,7 +144,7 @@ StarNameDatabase* StarNameDatabase::readNames(istream& in)
|
|||
if (failed)
|
||||
{
|
||||
delete db;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue