Remove basictypes.h and use standard c++11 types

pull/110/head
Hleb Valoshka 2018-07-03 19:52:34 +03:00
parent 5097d204d0
commit 73638c116d
75 changed files with 886 additions and 995 deletions

View File

@ -38,7 +38,6 @@ UTIL_SOURCES = \
src/celutil/timer.cpp
UTIL_HEADERS = \
src/celutil/basictypes.h \
src/celutil/bigfix.h \
src/celutil/bytes.h \
src/celutil/color.h \

View File

@ -40,8 +40,8 @@ static const int HipStarRecordLength = 451;
static const int HipComponentRecordLength = 239;
static const int TycStarRecordLength = 351;
static uint32 NullCCDMIdentifier = 0xffffffff;
static uint32 NullCatalogNumber = 0xffffffff;
static uint32_t NullCCDMIdentifier = 0xffffffff;
static uint32_t NullCatalogNumber = 0xffffffff;
static int verbose, dropstars;
@ -53,20 +53,20 @@ public:
void write(ostream& /*out*/);
void analyze();
uint32 HIPCatalogNumber{NullCatalogNumber};
uint32 HDCatalogNumber{NullCatalogNumber};
uint32_t HIPCatalogNumber{NullCatalogNumber};
uint32_t HDCatalogNumber{NullCatalogNumber};
float ascension{0.0f};
float declination{0.0f};
float parallax{0.0f};
float appMag{0.0f};
StellarClass stellarClass;
uint32 CCDMIdentifier{NullCCDMIdentifier};
uint8 starsWithCCDM{0};
uint8 nComponents{1};
uint8 parallaxError{0};
uint tycline{0};
uint status;
uint32_t CCDMIdentifier{NullCCDMIdentifier};
uint8_t starsWithCCDM{0};
uint8_t nComponents{1};
uint8_t parallaxError{0};
unsigned int tycline{0};
unsigned int status;
float e_RA{0.0f}; // Errors in Right Ascension,
float e_DE{0.0f}; // Declination,
float e_Mag{0.0f}; // and Magnitude
@ -182,7 +182,7 @@ struct HIPCatalogComparePredicate
return star0->HIPCatalogNumber < star1->HIPCatalogNumber;
}
bool operator()(const HipparcosStar* star0, uint32 hip)
bool operator()(const HipparcosStar* star0, uint32_t hip)
{
return star0->HIPCatalogNumber < hip;
}
@ -222,11 +222,11 @@ vector<HipparcosStar> companions;
vector<HipparcosComponent> components;
vector<HipparcosStar*> starIndex;
typedef map<uint32, MultistarSystem*> MultistarSystemCatalog;
typedef map<uint32_t, MultistarSystem*> MultistarSystemCatalog;
MultistarSystemCatalog starSystems;
HipparcosStar* findStar(uint32 hip)
HipparcosStar* findStar(uint32_t hip)
{
HIPCatalogComparePredicate pred;
@ -508,7 +508,7 @@ bool CheckStarRecord(istream& in)
if (star.parallax < 0.0f || parallaxError / star.parallax > 1.0f)
star.parallaxError = 255u;
else
star.parallaxError = (uint8) (parallaxError / star.parallax * 200);
star.parallaxError = (uint8_t) (parallaxError / star.parallax * 200);
}
if (sscanf(buf + 79, "%f", &star.parallax) != 1)
@ -723,9 +723,9 @@ bool ReadStarRecord(istream& in)
star.CCDMIdentifier = asc << 16 | (dec & 0xffff);
sscanf(buf + 340, "%d", &n);
star.starsWithCCDM = (uint8) n;
star.starsWithCCDM = (uint8_t) n;
sscanf(buf + 343, "%d", &n);
star.nComponents = (uint8) n;
star.nComponents = (uint8_t) n;
}
char* spectralType = buf + 435;
@ -751,7 +751,7 @@ bool ReadStarRecord(istream& in)
if (star.parallax < 0.0f || parallaxError / star.parallax > 1.0f)
star.parallaxError = 255u;
else
star.parallaxError = (uint8) (parallaxError / star.parallax * 200);
star.parallaxError = (uint8_t) (parallaxError / star.parallax * 200);
}
if (sscanf(buf + 105, "%f", &star.e_RA) != 1)
@ -799,7 +799,7 @@ bool ReadComponentRecord(istream& in)
in.read(buf, HipComponentRecordLength);
uint32 hip;
uint32_t hip;
if (sscanf(buf + 42, "%ud", &hip) != 1)
{
cout << "Missing HIP catalog number for component.\n";

View File

@ -111,14 +111,14 @@ void M3DTriangleMesh::setMatrix(const Matrix4f& m)
matrix = m;
}
Vector3f M3DTriangleMesh::getVertex(uint16 n) const
Vector3f M3DTriangleMesh::getVertex(uint16_t n) const
{
return points[n];
}
uint16 M3DTriangleMesh::getVertexCount() const
uint16_t M3DTriangleMesh::getVertexCount() const
{
return (uint16) (points.size());
return (uint16_t) (points.size());
}
void M3DTriangleMesh::addVertex(const Vector3f& p)
@ -126,14 +126,14 @@ void M3DTriangleMesh::addVertex(const Vector3f& p)
points.push_back(p);
}
Vector2f M3DTriangleMesh::getTexCoord(uint16 n) const
Vector2f M3DTriangleMesh::getTexCoord(uint16_t n) const
{
return texCoords[n];
}
uint16 M3DTriangleMesh::getTexCoordCount() const
uint16_t M3DTriangleMesh::getTexCoordCount() const
{
return (uint16) (texCoords.size());
return (uint16_t) (texCoords.size());
}
void M3DTriangleMesh::addTexCoord(const Vector2f& p)
@ -141,7 +141,7 @@ void M3DTriangleMesh::addTexCoord(const Vector2f& p)
texCoords.push_back(p);
}
void M3DTriangleMesh::getFace(uint16 n, uint16& v0, uint16& v1, uint16& v2) const
void M3DTriangleMesh::getFace(uint16_t n, uint16_t& v0, uint16_t& v1, uint16_t& v2) const
{
int m = (int) n * 3;
v0 = faces[m];
@ -149,31 +149,31 @@ void M3DTriangleMesh::getFace(uint16 n, uint16& v0, uint16& v1, uint16& v2) cons
v2 = faces[m + 2];
}
uint16 M3DTriangleMesh::getFaceCount() const
uint16_t M3DTriangleMesh::getFaceCount() const
{
return (uint16) (faces.size() / 3);
return (uint16_t) (faces.size() / 3);
}
void M3DTriangleMesh::addFace(uint16 v0, uint16 v1, uint16 v2)
void M3DTriangleMesh::addFace(uint16_t v0, uint16_t v1, uint16_t v2)
{
faces.insert(faces.end(), v0);
faces.insert(faces.end(), v1);
faces.insert(faces.end(), v2);
}
uint32 M3DTriangleMesh::getSmoothingGroups(uint16 face) const
uint32_t M3DTriangleMesh::getSmoothingGroups(uint16_t face) const
{
return face < smoothingGroups.size() ? smoothingGroups[face] : 0;
}
void M3DTriangleMesh::addSmoothingGroups(uint32 smGroups)
void M3DTriangleMesh::addSmoothingGroups(uint32_t smGroups)
{
smoothingGroups.insert(smoothingGroups.end(), smGroups);
}
uint16 M3DTriangleMesh::getSmoothingGroupCount() const
uint16_t M3DTriangleMesh::getSmoothingGroupCount() const
{
return (uint16) (smoothingGroups.size());
return (uint16_t) (smoothingGroups.size());
}
void M3DTriangleMesh::addMeshMaterialGroup(M3DMeshMaterialGroup* matGroup)
@ -181,12 +181,12 @@ void M3DTriangleMesh::addMeshMaterialGroup(M3DMeshMaterialGroup* matGroup)
meshMaterialGroups.push_back(matGroup);
}
M3DMeshMaterialGroup* M3DTriangleMesh::getMeshMaterialGroup(uint32 index) const
M3DMeshMaterialGroup* M3DTriangleMesh::getMeshMaterialGroup(uint32_t index) const
{
return meshMaterialGroups[index];
}
uint32 M3DTriangleMesh::getMeshMaterialGroupCount() const
uint32_t M3DTriangleMesh::getMeshMaterialGroupCount() const
{
return meshMaterialGroups.size();
}
@ -198,12 +198,12 @@ M3DModel::~M3DModel()
delete triMesh;
}
M3DTriangleMesh* M3DModel::getTriMesh(uint32 n)
M3DTriangleMesh* M3DModel::getTriMesh(uint32_t n)
{
return n < triMeshes.size() ? triMeshes[n] : nullptr;
}
uint32 M3DModel::getTriMeshCount()
uint32_t M3DModel::getTriMeshCount()
{
return triMeshes.size();
}
@ -232,12 +232,12 @@ M3DScene::~M3DScene()
delete material;
}
M3DModel* M3DScene::getModel(uint32 n) const
M3DModel* M3DScene::getModel(uint32_t n) const
{
return n < models.size() ? models[n] : nullptr;
}
uint32 M3DScene::getModelCount() const
uint32_t M3DScene::getModelCount() const
{
return models.size();
}
@ -247,12 +247,12 @@ void M3DScene::addModel(M3DModel* model)
models.insert(models.end(), model);
}
M3DMaterial* M3DScene::getMaterial(uint32 n) const
M3DMaterial* M3DScene::getMaterial(uint32_t n) const
{
return n < materials.size() ? materials[n] : nullptr;
}
uint32 M3DScene::getMaterialCount() const
uint32_t M3DScene::getMaterialCount() const
{
return materials.size();
}

View File

@ -12,7 +12,6 @@
#include <vector>
#include <string>
#include <celutil/basictypes.h>
#include <Eigen/Core>
class M3DColor
@ -61,7 +60,7 @@ class M3DMeshMaterialGroup
{
public:
std::string materialName;
std::vector<uint16> faces;
std::vector<uint16_t> faces;
};
@ -76,31 +75,31 @@ class M3DTriangleMesh
Eigen::Matrix4f getMatrix() const;
void setMatrix(const Eigen::Matrix4f&);
Eigen::Vector3f getVertex(uint16) const;
uint16 getVertexCount() const;
Eigen::Vector3f getVertex(uint16_t) const;
uint16_t getVertexCount() const;
void addVertex(const Eigen::Vector3f&);
Eigen::Vector2f getTexCoord(uint16) const;
uint16 getTexCoordCount() const;
Eigen::Vector2f getTexCoord(uint16_t) const;
uint16_t getTexCoordCount() const;
void addTexCoord(const Eigen::Vector2f&);
void getFace(uint16, uint16&, uint16&, uint16&) const;
uint16 getFaceCount() const;
void addFace(uint16, uint16, uint16);
void getFace(uint16_t, uint16_t&, uint16_t&, uint16_t&) const;
uint16_t getFaceCount() const;
void addFace(uint16_t, uint16_t, uint16_t);
void addSmoothingGroups(uint32);
uint32 getSmoothingGroups(uint16) const;
uint16 getSmoothingGroupCount() const;
void addSmoothingGroups(uint32_t);
uint32_t getSmoothingGroups(uint16_t) const;
uint16_t getSmoothingGroupCount() const;
void addMeshMaterialGroup(M3DMeshMaterialGroup* matGroup);
M3DMeshMaterialGroup* getMeshMaterialGroup(uint32) const;
uint32 getMeshMaterialGroupCount() const;
M3DMeshMaterialGroup* getMeshMaterialGroup(uint32_t) const;
uint32_t getMeshMaterialGroupCount() const;
private:
std::vector<Eigen::Vector3f> points;
std::vector<Eigen::Vector2f> texCoords;
std::vector<uint16> faces;
std::vector<uint32> smoothingGroups;
std::vector<uint16_t> faces;
std::vector<uint32_t> smoothingGroups;
std::vector<M3DMeshMaterialGroup*> meshMaterialGroups;
Eigen::Matrix4f matrix;
};
@ -112,8 +111,8 @@ class M3DModel
M3DModel() = default;
~M3DModel();
M3DTriangleMesh* getTriMesh(uint32);
uint32 getTriMeshCount();
M3DTriangleMesh* getTriMesh(uint32_t);
uint32_t getTriMeshCount();
void addTriMesh(M3DTriangleMesh*);
void setName(const std::string&);
const std::string getName() const;
@ -130,12 +129,12 @@ class M3DScene
M3DScene() = default;
~M3DScene();
M3DModel* getModel(uint32) const;
uint32 getModelCount() const;
M3DModel* getModel(uint32_t) const;
uint32_t getModelCount() const;
void addModel(M3DModel*);
M3DMaterial* getMaterial(uint32) const;
uint32 getMaterialCount() const;
M3DMaterial* getMaterial(uint32_t) const;
uint32_t getMaterialCount() const;
void addMaterial(M3DMaterial*);
M3DColor getBackgroundColor() const;

View File

@ -28,26 +28,26 @@ static int read3DSChunk(ifstream& in,
static int logIndent = 0;
static int32 readInt(ifstream& in)
static int32_t readInt(ifstream& in)
{
int32 ret;
in.read((char *) &ret, sizeof(int32));
int32_t ret;
in.read((char *) &ret, sizeof(int32_t));
LE_TO_CPU_INT32(ret, ret);
return ret;
}
static int16 readShort(ifstream& in)
static int16_t readShort(ifstream& in)
{
int16 ret;
in.read((char *) &ret, sizeof(int16));
int16_t ret;
in.read((char *) &ret, sizeof(int16_t));
LE_TO_CPU_INT16(ret, ret);
return ret;
}
static uint16 readUshort(ifstream& in)
static uint16_t readUshort(ifstream& in)
{
uint16 ret;
in.read((char *) &ret, sizeof(uint16));
uint16_t ret;
in.read((char *) &ret, sizeof(uint16_t));
LE_TO_CPU_INT16(ret, ret);
return ret;
}
@ -113,7 +113,7 @@ void indent()
cout << " ";
}
void logChunk(uint16 /*chunkType*/ /*, int chunkSize*/)
void logChunk(uint16_t /*chunkType*/ /*, int chunkSize*/)
{
#if 0
const char* name = nullptr;
@ -214,7 +214,7 @@ int read3DSChunk(ifstream& in,
void* obj)
{
unsigned short chunkType = readUshort(in);
int32 chunkSize = readInt(in);
int32_t chunkSize = readInt(in);
int contentSize = chunkSize - 6;
//logChunk(chunkType/*, chunkSize*/);
@ -320,7 +320,7 @@ bool stubProcessChunk(/* ifstream& in,
void readPointArray(ifstream& in, M3DTriangleMesh* triMesh)
{
uint16 nPoints = readUshort(in);
uint16_t nPoints = readUshort(in);
for (int i = 0; i < (int) nPoints; i++)
{
@ -334,7 +334,7 @@ void readPointArray(ifstream& in, M3DTriangleMesh* triMesh)
void readTextureCoordArray(ifstream& in, M3DTriangleMesh* triMesh)
{
uint16 nPoints = readUshort(in);
uint16_t nPoints = readUshort(in);
for (int i = 0; i < (int) nPoints; i++)
{
@ -351,7 +351,7 @@ bool processFaceArrayChunk(ifstream& in,
void* obj)
{
auto* triMesh = (M3DTriangleMesh*) obj;
uint16 nFaces;
uint16_t nFaces;
M3DMeshMaterialGroup* matGroup;
switch (chunkType)
@ -362,9 +362,9 @@ bool processFaceArrayChunk(ifstream& in,
matGroup->materialName = readString(in);
nFaces = readUshort(in);
for (uint16 i = 0; i < nFaces; i++)
for (uint16_t i = 0; i < nFaces; i++)
{
uint16 faceIndex = readUshort(in);
uint16_t faceIndex = readUshort(in);
matGroup->faces.push_back(faceIndex);
}
@ -374,9 +374,9 @@ bool processFaceArrayChunk(ifstream& in,
case M3DCHUNK_MESH_SMOOTH_GROUP:
nFaces = triMesh->getFaceCount();
for (uint16 i = 0; i < nFaces; i++)
for (uint16_t i = 0; i < nFaces; i++)
{
uint32 groups = (uint32) readInt(in);
auto groups = (uint32_t) readInt(in);
triMesh->addSmoothingGroups(groups);
}
return true;
@ -387,14 +387,14 @@ bool processFaceArrayChunk(ifstream& in,
void readFaceArray(ifstream& in, M3DTriangleMesh* triMesh, int contentSize)
{
uint16 nFaces = readUshort(in);
uint16_t nFaces = readUshort(in);
for (int i = 0; i < (int) nFaces; i++)
{
uint16 v0 = readUshort(in);
uint16 v1 = readUshort(in);
uint16 v2 = readUshort(in);
/*uint16 flags = */ readUshort(in);
uint16_t v0 = readUshort(in);
uint16_t v1 = readUshort(in);
uint16_t v2 = readUshort(in);
/*uint16_t flags = */ readUshort(in);
triMesh->addFace(v0, v1, v2);
}
@ -630,7 +630,7 @@ M3DScene* Read3DSFile(ifstream& in)
return nullptr;
}
int32 chunkSize = readInt(in);
int32_t chunkSize = readInt(in);
if (in.bad())
{
DPRINTF(0, "Read3DSFile: Error reading 3DS file.\n");

View File

@ -14,7 +14,6 @@
#include <cstdio>
#include <utility>
#include <ctime>
#include <celutil/basictypes.h>
#include <celmath/mathlib.h>
#include "celestia.h"
#include "astro.h"
@ -496,7 +495,7 @@ astro::Date::Date(int Y, int M, int D)
astro::Date::Date(double jd)
{
int64 a = (int64) floor(jd + 0.5);
auto a = (int64_t) floor(jd + 0.5);
wday = (a + 1) % 7;
double c;
if (a < 2299161)
@ -505,20 +504,20 @@ astro::Date::Date(double jd)
}
else
{
double b = (double) ((int64) floor((a - 1867216.25) / 36524.25));
c = a + b - (int64) floor(b / 4) + 1525;
double b = (double) ((int64_t) floor((a - 1867216.25) / 36524.25));
c = a + b - (int64_t) floor(b / 4) + 1525;
}
int64 d = (int64) floor((c - 122.1) / 365.25);
int64 e = (int64) floor(365.25 * d);
int64 f = (int64) floor((c - e) / 30.6001);
auto d = (int64_t) floor((c - 122.1) / 365.25);
auto e = (int64_t) floor(365.25 * d);
auto f = (int64_t) floor((c - e) / 30.6001);
double dday = c - e - (int64) floor(30.6001 * f) + ((jd + 0.5) - a);
double dday = c - e - (int64_t) floor(30.6001 * f) + ((jd + 0.5) - a);
// This following used to be 14.0, but gcc was computing it incorrectly, so
// it was changed to 14
month = (int) (f - 1 - 12 * (int64) (f / 14));
year = (int) (d - 4715 - (int64) ((7.0 + month) / 10.0));
month = (int) (f - 1 - 12 * (int64_t) (f / 14));
year = (int) (d - 4715 - (int64_t) ((7.0 + month) / 10.0));
day = (int) dday;
double dhour = (dday - day) * 24;

View File

@ -322,9 +322,9 @@ class Body
VelocityVector = 0x10,
};
bool referenceMarkVisible(uint32) const;
uint32 getVisibleReferenceMarks() const;
void setVisibleReferenceMarks(uint32);
bool referenceMarkVisible(uint32_t) const;
uint32_t getVisibleReferenceMarks() const;
void setVisibleReferenceMarks(uint32_t);
void addReferenceMark(ReferenceMark* refMark);
void removeReferenceMark(const std::string& tag);
ReferenceMark* findReferenceMark(const std::string& tag) const;

View File

@ -45,7 +45,7 @@ struct XrefEntryPredicate
};
Star* CatalogCrossReference::lookup(uint32 catalogNumber) const
Star* CatalogCrossReference::lookup(uint32_t catalogNumber) const
{
Entry e;
e.catalogNumber = catalogNumber;
@ -64,7 +64,7 @@ Star* CatalogCrossReference::lookup(uint32 catalogNumber) const
Star* CatalogCrossReference::lookup(const string& name) const
{
uint32 catalogNumber = parse(name);
uint32_t catalogNumber = parse(name);
if (catalogNumber == InvalidCatalogNumber)
return nullptr;
@ -72,7 +72,7 @@ Star* CatalogCrossReference::lookup(const string& name) const
}
uint32 CatalogCrossReference::parse(const string& name) const
uint32_t CatalogCrossReference::parse(const string& name) const
{
if (compareIgnoringCase(name, prefix, prefix.length()) != 0)
return InvalidCatalogNumber;
@ -107,7 +107,7 @@ uint32 CatalogCrossReference::parse(const string& name) const
}
void CatalogCrossReference::addEntry(uint32 catalogNumber, Star* star)
void CatalogCrossReference::addEntry(uint32_t catalogNumber, Star* star)
{
Entry e;
e.catalogNumber = catalogNumber;
@ -129,12 +129,12 @@ void CatalogCrossReference::reserve(size_t n)
}
static uint32 readUint32(istream& in)
static uint32_t 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];
return ((uint32_t) b[3] << 24) + ((uint32_t) b[2] << 16)
+ ((uint32_t) b[1] << 8) + (uint32_t) b[0];
}
@ -143,7 +143,7 @@ CatalogCrossReference* ReadCatalogCrossReference(istream& in,
{
auto* xref = new CatalogCrossReference();
uint32 nEntries = readUint32(in);
uint32_t nEntries = readUint32(in);
if (!in.good())
{
delete xref;
@ -152,10 +152,10 @@ CatalogCrossReference* ReadCatalogCrossReference(istream& in,
xref->reserve(nEntries);
for (uint32 i = 0; i < nEntries; i++)
for (uint32_t i = 0; i < nEntries; i++)
{
uint32 catNo1 = readUint32(in);
uint32 catNo2 = readUint32(in);
uint32_t catNo1 = readUint32(in);
uint32_t catNo2 = readUint32(in);
Star* star = stardb.find(catNo2);
if (star != nullptr)
xref->addEntry(catNo1, star);

View File

@ -25,11 +25,11 @@ class CatalogCrossReference
std::string getPrefix() const;
void setPrefix(const std::string&);
uint32 parse(const std::string&) const;
Star* lookup(uint32) const;
uint32_t parse(const std::string&) const;
Star* lookup(uint32_t) const;
Star* lookup(const std::string&) const;
void addEntry(uint32 catalogNumber, Star* star);
void addEntry(uint32_t catalogNumber, Star* star);
void sortEntries();
void reserve(size_t);
@ -41,7 +41,7 @@ class CatalogCrossReference
class Entry
{
public:
uint32 catalogNumber;
uint32_t catalogNumber;
Star* star;
};

View File

@ -21,42 +21,42 @@ using namespace std;
struct DDPixelFormat
{
uint32 size;
uint32 flags;
uint32 fourCC;
uint32 bpp;
uint32 redMask;
uint32 greenMask;
uint32 blueMask;
uint32 alphaMask;
uint32_t size;
uint32_t flags;
uint32_t fourCC;
uint32_t bpp;
uint32_t redMask;
uint32_t greenMask;
uint32_t blueMask;
uint32_t alphaMask;
};
struct DDSCaps
{
uint32 caps;
uint32 caps2;
uint32 caps3;
uint32 caps4;
uint32_t caps;
uint32_t caps2;
uint32_t caps3;
uint32_t caps4;
};
struct DDColorKey
{
uint32 lowVal;
uint32 highVal;
uint32_t lowVal;
uint32_t highVal;
};
struct DDSurfaceDesc
{
uint32 size;
uint32 flags;
uint32 height;
uint32 width;
uint32 pitch;
uint32 depth;
uint32 mipMapLevels;
uint32 alphaBitDepth;
uint32 reserved;
uint32 surface;
uint32_t size;
uint32_t flags;
uint32_t height;
uint32_t width;
uint32_t pitch;
uint32_t depth;
uint32_t mipMapLevels;
uint32_t alphaBitDepth;
uint32_t reserved;
uint32_t surface;
DDColorKey ckDestOverlay;
DDColorKey ckDestBlt;
@ -66,16 +66,16 @@ struct DDSurfaceDesc
DDPixelFormat format;
DDSCaps caps;
uint32 textureStage;
uint32_t textureStage;
};
static uint32 FourCC(const char* s)
static uint32_t FourCC(const char* s)
{
return (((uint32) s[3] << 24) |
((uint32) s[2] << 16) |
((uint32) s[1] << 8) |
(uint32) s[0]);
return (((uint32_t) s[3] << 24) |
((uint32_t) s[2] << 16) |
((uint32_t) s[1] << 8) |
(uint32_t) s[0]);
}

View File

@ -27,7 +27,7 @@ using namespace Eigen;
using namespace std;
void DeepSkyObject::setCatalogNumber(uint32 n)
void DeepSkyObject::setCatalogNumber(uint32_t n)
{
catalogNumber = n;
}

View File

@ -13,7 +13,6 @@
#include <vector>
#include <string>
#include <iostream>
#include <celutil/basictypes.h>
#include <celmath/ray.h>
#include <celengine/glcontext.h>
#include <celengine/parser.h>
@ -35,11 +34,11 @@ class DeepSkyObject
DeepSkyObject() = default;
virtual ~DeepSkyObject() = default;
inline uint32 getCatalogNumber() const
inline uint32_t getCatalogNumber() const
{
return catalogNumber;
}
void setCatalogNumber(uint32);
void setCatalogNumber(uint32_t);
Eigen::Vector3d getPosition() const;
void setPosition(const Eigen::Vector3d&);
@ -100,7 +99,7 @@ class DeepSkyObject
};
private:
uint32 catalogNumber{ InvalidCatalogNumber };
uint32_t catalogNumber{ InvalidCatalogNumber };
Eigen::Vector3d position{ 0, 0, 0 };
Eigen::Quaternionf orientation{ Eigen::Quaternionf::Identity() };
float radius{ 1 };

View File

@ -71,7 +71,7 @@ DSODatabase::~DSODatabase()
}
DeepSkyObject* DSODatabase::find(const uint32 catalogNumber) const
DeepSkyObject* DSODatabase::find(const uint32_t catalogNumber) const
{
Galaxy refDSO; //terrible hack !!
refDSO.setCatalogNumber(catalogNumber);
@ -95,7 +95,7 @@ DeepSkyObject* DSODatabase::find(const string& name) const
if (namesDB != nullptr)
{
uint32 catalogNumber = namesDB->findCatalogNumberByName(name);
uint32_t catalogNumber = namesDB->findCatalogNumberByName(name);
if (catalogNumber != DeepSkyObject::InvalidCatalogNumber)
return find(catalogNumber);
}
@ -118,7 +118,7 @@ vector<string> DSODatabase::getCompletion(const string& name) const
string DSODatabase::getDSOName(const DeepSkyObject* const & dso, bool i18n) const
{
uint32 catalogNumber = dso->getCatalogNumber();
uint32_t catalogNumber = dso->getCatalogNumber();
if (namesDB != nullptr)
{
@ -236,11 +236,11 @@ bool DSODatabase::load(istream& in, const string& resourcePath)
objType = tokenizer.getNameValue();
bool autoGenCatalogNumber = true;
uint32 objCatalogNumber = DeepSkyObject::InvalidCatalogNumber;
uint32_t objCatalogNumber = DeepSkyObject::InvalidCatalogNumber;
if (tokenizer.getTokenType() == Tokenizer::TokenNumber)
{
autoGenCatalogNumber = false;
objCatalogNumber = (uint32) tokenizer.getNumberValue();
objCatalogNumber = (uint32_t) tokenizer.getNumberValue();
tokenizer.nextToken();
}
@ -411,7 +411,7 @@ void DSODatabase::buildOctree()
void DSODatabase::calcAvgAbsMag()
{
uint32 nDSOeff = size();
uint32_t nDSOeff = size();
for (int i = 0; i < nDSOs; ++i)
{
double DSOmag = DSOs[i]->getAbsoluteMagnitude();

View File

@ -33,10 +33,10 @@ class DSODatabase
~DSODatabase();
inline DeepSkyObject* getDSO(const uint32) const;
inline uint32 size() const;
inline DeepSkyObject* getDSO(const uint32_t) const;
inline uint32_t size() const;
DeepSkyObject* find(const uint32 catalogNumber) const;
DeepSkyObject* find(const uint32_t catalogNumber) const;
DeepSkyObject* find(const std::string&) const;
std::vector<std::string> getCompletion(const std::string&) const;
@ -79,19 +79,19 @@ private:
DSONameDatabase* namesDB{ nullptr };
DeepSkyObject** catalogNumberIndex{ nullptr };
DSOOctree* octreeRoot{ nullptr };
uint32 nextAutoCatalogNumber{ 0xfffffffe };
uint32_t nextAutoCatalogNumber{ 0xfffffffe };
double avgAbsMag{ 0.0 };
};
DeepSkyObject* DSODatabase::getDSO(const uint32 n) const
DeepSkyObject* DSODatabase::getDSO(const uint32_t n) const
{
return *(DSOs + n);
}
uint32 DSODatabase::size() const
uint32_t DSODatabase::size() const
{
return nDSOs;
}

View File

@ -15,7 +15,7 @@
using namespace std;
//NOTE: this could be expanded in the near future, so we place it here:
uint32 DSONameDatabase::findCatalogNumberByName(const string& name) const
uint32_t DSONameDatabase::findCatalogNumberByName(const string& name) const
{
return getCatalogNumberByName(name);
}

View File

@ -23,7 +23,7 @@ class DSONameDatabase: public NameDatabase<DeepSkyObject>
DSONameDatabase() {};
uint32 findCatalogNumberByName(const std::string&) const;
uint32_t findCatalogNumberByName(const std::string&) const;
};
#endif // _DSONAME_H_

View File

@ -11,7 +11,6 @@
#define _CELENGINE_IMAGE_H_
#include <string>
#include <celutil/basictypes.h>
// The image class supports multiple GL formats, including compressed ones.
// Mipmaps may be stored within an image as well. The mipmaps are stored in

View File

@ -16,13 +16,13 @@ using namespace Eigen;
using namespace std;
static map<string, uint32> FeatureNameToFlag;
static map<string, uint32_t> FeatureNameToFlag;
static bool featureTableInitialized = false;
struct FeatureNameEntry
{
const char* name;
uint32 flag;
uint32_t flag;
};
FeatureNameEntry FeatureNames[] =
@ -132,13 +132,13 @@ void Location::setInfoURL(const string&)
}
uint32 Location::getFeatureType() const
uint32_t Location::getFeatureType() const
{
return featureType;
}
void Location::setFeatureType(uint32 _featureType)
void Location::setFeatureType(uint32_t _featureType)
{
featureType = _featureType;
}
@ -155,13 +155,13 @@ static void initFeatureTypeTable()
}
uint32 Location::parseFeatureType(const string& s)
uint32_t Location::parseFeatureType(const string& s)
{
if (!featureTableInitialized)
initFeatureTypeTable();
int flag = FeatureNameToFlag[s];
return flag != 0 ? flag : (uint32) Other;
return flag != 0 ? flag : (uint32_t) Other;
}

View File

@ -11,7 +11,6 @@
#define _CELENGINE_LOCATION_H_
#include <string>
#include <celutil/basictypes.h>
#include <celutil/color.h>
#include <Eigen/Core>
@ -35,8 +34,8 @@ class Location
float getImportance() const;
void setImportance(float);
uint32 getFeatureType() const;
void setFeatureType(uint32);
uint32_t getFeatureType() const;
void setFeatureType(uint32_t);
std::string getInfoURL() const;
void setInfoURL(const std::string&);
@ -53,7 +52,7 @@ class Location
Eigen::Vector3d getPlanetocentricPosition(double) const;
Eigen::Vector3d getHeliocentricPosition(double) const;
static uint32 parseFeatureType(const std::string&);
static uint32_t parseFeatureType(const std::string&);
enum FeatureType
{
@ -98,7 +97,7 @@ class Location
Eigen::Vector3f position{ Eigen::Vector3f::Zero() };
float size{ 0.0f };
float importance{ -1.0f };
uint32 featureType{ Other };
uint32_t featureType{ Other };
bool overrideLabelColor{ false };
Color labelColor{ 1.0f, 1.0f, 1.0f };
std::string* infoURL{ nullptr };

View File

@ -178,7 +178,7 @@ Geometry* GeometryInfo::load(const string& resolvedFilename)
// impact rendering performance. Ideally uniquification of materials
// would be performed just once when the model was created, but
// that's not the case.
uint32 originalMaterialCount = model->getMaterialCount();
uint32_t originalMaterialCount = model->getMaterialCount();
model->uniquifyMaterials();
// Sort the submeshes roughly by opacity. This will eliminate a
@ -324,8 +324,8 @@ ConvertTriangleMesh(M3DTriangleMesh& mesh,
// Create the attribute set. Always include positions and normals, texture coords
// are optional.
Mesh::VertexAttribute attributes[8];
uint32 nAttributes = 0;
uint32 offset = 0;
uint32_t nAttributes = 0;
uint32_t offset = 0;
// Position attribute are required
attributes[nAttributes] = Mesh::VertexAttribute(Mesh::Position, Mesh::Float3, 0);
@ -344,7 +344,7 @@ ConvertTriangleMesh(M3DTriangleMesh& mesh,
offset += 8;
}
uint32 vertexSize = offset;
uint32_t vertexSize = offset;
// bool smooth = (mesh.getSmoothingGroupCount() == nFaces);
@ -362,7 +362,7 @@ ConvertTriangleMesh(M3DTriangleMesh& mesh,
// generate face normals
for (int i = 0; i < nFaces; i++)
{
uint16 v0, v1, v2;
uint16_t v0, v1, v2;
mesh.getFace(i, v0, v1, v2);
faceCounts[v0]++;
@ -397,7 +397,7 @@ ConvertTriangleMesh(M3DTriangleMesh& mesh,
for (int i = 0; i < nFaces; i++)
{
uint16 v0, v1, v2;
uint16_t v0, v1, v2;
mesh.getFace(i, v0, v1, v2);
vertexFaces[v0][faceCounts[v0]--] = i;
vertexFaces[v1][faceCounts[v1]--] = i;
@ -407,9 +407,9 @@ ConvertTriangleMesh(M3DTriangleMesh& mesh,
// average face normals to compute the vertex normals
for (int i = 0; i < nFaces; i++)
{
uint16 v0, v1, v2;
uint16_t v0, v1, v2;
mesh.getFace(i, v0, v1, v2);
// uint32 smoothingGroups = mesh.getSmoothingGroups(i);
// uint32_t smoothingGroups = mesh.getSmoothingGroups(i);
Vector3f v = Vector3f::Zero();
for (int j = 1; j <= vertexFaces[v0][0]; j++)
@ -449,7 +449,7 @@ ConvertTriangleMesh(M3DTriangleMesh& mesh,
for (int i = 0; i < nFaces; i++)
{
uint16 triVert[3];
uint16_t triVert[3];
mesh.getFace(i, triVert[0], triVert[1], triVert[2]);
for (unsigned int j = 0; j < 3; j++)
@ -478,26 +478,26 @@ ConvertTriangleMesh(M3DTriangleMesh& mesh,
newMesh->setVertexDescription(Mesh::VertexDescription(vertexSize, nAttributes, attributes));
newMesh->setVertices(nFaces * 3, vertexData);
for (uint32 i = 0; i < mesh.getMeshMaterialGroupCount(); ++i)
for (uint32_t i = 0; i < mesh.getMeshMaterialGroupCount(); ++i)
{
M3DMeshMaterialGroup* matGroup = mesh.getMeshMaterialGroup(i);
// Vertex lists are not indexed, so the conversion to an indexed format is
// trivial (although much space is wasted storing unnecessary indices.)
uint32 nMatGroupFaces = matGroup->faces.size();
uint32_t nMatGroupFaces = matGroup->faces.size();
uint32* indices = new uint32[nMatGroupFaces * 3];
for (uint32 j = 0; j < nMatGroupFaces; ++j)
auto indices = new uint32_t[nMatGroupFaces * 3];
for (uint32_t j = 0; j < nMatGroupFaces; ++j)
{
uint16 faceIndex = matGroup->faces[j];
uint16_t faceIndex = matGroup->faces[j];
indices[j * 3 + 0] = faceIndex * 3 + 0;
indices[j * 3 + 1] = faceIndex * 3 + 1;
indices[j * 3 + 2] = faceIndex * 3 + 2;
}
// Lookup the material index
uint32 materialIndex = 0;
for (uint32 j = 0; j < scene.getMaterialCount(); ++j)
uint32_t materialIndex = 0;
for (uint32_t j = 0; j < scene.getMaterialCount(); ++j)
{
if (matGroup->materialName == scene.getMaterial(j)->getName())
{
@ -541,7 +541,7 @@ Convert3DSModel(const M3DScene& scene, const string& texPath)
Model* model = new Model();
// Convert the materials
for (uint32 i = 0; i < scene.getMaterialCount(); i++)
for (uint32_t i = 0; i < scene.getMaterialCount(); i++)
{
M3DMaterial* material = scene.getMaterial(i);
Material* newMaterial = new Material();
@ -574,7 +574,7 @@ Convert3DSModel(const M3DScene& scene, const string& texPath)
// Convert all models in the scene. Some confusing terminology: a 3ds 'scene' is the same
// as a Celestia model, and a 3ds 'model' is the same as a Celestia mesh.
for (uint32 i = 0; i < scene.getModelCount(); i++)
for (uint32_t i = 0; i < scene.getModelCount(); i++)
{
M3DModel* model3ds = scene.getModel(i);
if (model3ds)

View File

@ -17,7 +17,6 @@
#include <iostream>
#include <map>
#include <vector>
#include <celutil/basictypes.h>
#include <celutil/debug.h>
#include <celutil/util.h>
#include <celutil/utf8.h>
@ -27,24 +26,24 @@
template <class OBJ> class NameDatabase
{
public:
typedef std::map<std::string, uint32, CompareIgnoringCasePredicate> NameIndex;
typedef std::multimap<uint32, std::string> NumberIndex;
typedef std::map<std::string, uint32_t, CompareIgnoringCasePredicate> NameIndex;
typedef std::multimap<uint32_t, std::string> NumberIndex;
public:
NameDatabase() {};
uint32 getNameCount() const;
uint32_t getNameCount() const;
void add(const uint32, const std::string&);
void add(const uint32_t, const std::string&);
// delete all names associated with the specified catalog number
void erase(const uint32);
void erase(const uint32_t);
uint32 getCatalogNumberByName(const std::string&) const;
std::string getNameByCatalogNumber(const uint32) const;
uint32_t getCatalogNumberByName(const std::string&) const;
std::string getNameByCatalogNumber(const uint32_t) const;
NumberIndex::const_iterator getFirstNameIter(const uint32 catalogNumber) const;
NumberIndex::const_iterator getFirstNameIter(const uint32_t catalogNumber) const;
NumberIndex::const_iterator getFinalNameIter() const;
std::vector<std::string> getCompletion(const std::string& name) const;
@ -57,19 +56,19 @@ template <class OBJ> class NameDatabase
template <class OBJ>
uint32 NameDatabase<OBJ>::getNameCount() const
uint32_t NameDatabase<OBJ>::getNameCount() const
{
return nameIndex.size();
}
template <class OBJ>
void NameDatabase<OBJ>::add(const uint32 catalogNumber, const std::string& name)
void NameDatabase<OBJ>::add(const uint32_t catalogNumber, const std::string& name)
{
if (name.length() != 0)
{
#ifdef DEBUG
uint32 tmp;
uint32_t tmp;
if ((tmp = getCatalogNumberByName(name)) != OBJ::InvalidCatalogNumber)
DPRINTF(2,"Duplicated name '%s' on object with catalog numbers: %d and %d\n", name.c_str(), tmp, catalogNumber);
#endif
@ -83,14 +82,14 @@ void NameDatabase<OBJ>::add(const uint32 catalogNumber, const std::string& name)
template <class OBJ>
void NameDatabase<OBJ>::erase(const uint32 catalogNumber)
void NameDatabase<OBJ>::erase(const uint32_t catalogNumber)
{
numberIndex.erase(catalogNumber);
}
template <class OBJ>
uint32 NameDatabase<OBJ>::getCatalogNumberByName(const std::string& name) const
uint32_t NameDatabase<OBJ>::getCatalogNumberByName(const std::string& name) const
{
NameIndex::const_iterator iter = nameIndex.find(name);
@ -110,7 +109,7 @@ uint32 NameDatabase<OBJ>::getCatalogNumberByName(const std::string& name) const
// (not certain whether or not this behavior is in the STL spec.
// but it works on the implementations I've tried so far.)
template <class OBJ>
std::string NameDatabase<OBJ>::getNameByCatalogNumber(const uint32 catalogNumber) const
std::string NameDatabase<OBJ>::getNameByCatalogNumber(const uint32_t catalogNumber) const
{
if (catalogNumber == OBJ::InvalidCatalogNumber)
return "";
@ -131,9 +130,9 @@ std::string NameDatabase<OBJ>::getNameByCatalogNumber(const uint32 catalogNumber
// (not certain whether or not this behavior is in the STL spec.
// but it works on the implementations I've tried so far.)
template <class OBJ>
NameDatabase<OBJ>::NumberIndex::const_iterator NameDatabase<OBJ>::getFirstNameIter(const uint32 catalogNumber) const
NameDatabase<OBJ>::NumberIndex::const_iterator NameDatabase<OBJ>::getFirstNameIter(const uint32_t catalogNumber) const
{
NumberIndex::const_iterator iter = numberIndex.lower_bound(catalogNumber);
NumberIndex::const_iterator iter = numberIndex.lower_bound(catalogNumber);
if (iter == numberIndex.end() || iter->first != catalogNumber)
return getFinalNameIter();

View File

@ -557,13 +557,13 @@ void Observer::setDisplayedSurface(const string& surf)
}
uint32 Observer::getLocationFilter() const
uint32_t Observer::getLocationFilter() const
{
return locationFilter;
}
void Observer::setLocationFilter(uint32 _locationFilter)
void Observer::setLocationFilter(uint32_t _locationFilter)
{
locationFilter = _locationFilter;
}

View File

@ -146,8 +146,8 @@ public:
const std::string& getDisplayedSurface() const;
void setDisplayedSurface(const std::string&);
uint32 getLocationFilter() const;
void setLocationFilter(uint32);
uint32_t getLocationFilter() const;
void setLocationFilter(uint32_t);
void gotoSelection(const Selection&,
double gotoTime,
@ -311,7 +311,7 @@ public:
float fov{ (float) (PI / 4.0) };
bool reverseFlag{ false };
uint32 locationFilter{ ~0u };
uint32_t locationFilter{ ~0u };
std::string displayedSurface;
};

View File

@ -362,14 +362,14 @@ bool AssociativeArray::getNumber(const string& key, int& val) const
return true;
}
bool AssociativeArray::getNumber(const string& key, uint32& val) const
bool AssociativeArray::getNumber(const string& key, uint32_t& val) const
{
double ival;
if (!getNumber(key, ival))
return false;
val = (uint32) ival;
val = (uint32_t) ival;
return true;
}

View File

@ -16,7 +16,6 @@
#include <celmath/vecmath.h>
#include <celmath/quaternion.h>
#include <celutil/color.h>
#include <celutil/basictypes.h>
#include <celengine/tokenizer.h>
#include <Eigen/Core>
#include <Eigen/Geometry>
@ -37,7 +36,7 @@ class AssociativeArray
bool getNumber(const std::string&, double&) const;
bool getNumber(const std::string&, float&) const;
bool getNumber(const std::string&, int&) const;
bool getNumber(const std::string&, uint32&) const;
bool getNumber(const std::string&, uint32_t&) const;
bool getString(const std::string&, std::string&) const;
bool getBoolean(const std::string&, bool&) const;
bool getVector(const std::string&, Eigen::Vector3d&) const;

View File

@ -22,8 +22,6 @@
#include "rendcontext.h"
#include "texmanager.h"
#include <celutil/basictypes.h>
using namespace cmod;
using namespace Eigen;
using namespace std;
@ -80,9 +78,9 @@ using namespace std;
*/
// Same values as rand48()
static const uint64 A = ((uint64) 0x5deece66ul << 4) | 0xd;
static const uint64 C = 0xb;
static const uint64 M = ((uint64) 1 << 48) - 1;
static const uint64_t A = ((uint64_t) 0x5deece66ul << 4) | 0xd;
static const uint64_t C = 0xb;
static const uint64_t M = ((uint64_t) 1 << 48) - 1;
/*! Linear congruential random number generator that emulates
* rand48()
@ -92,12 +90,12 @@ class LCGRandomGenerator
public:
LCGRandomGenerator() : previous(0) = default;
LCGRandomGenerator(uint64 seed) :
LCGRandomGenerator(uint64_t seed) :
previous(seed)
{
}
uint64 randUint64()
uint64_t randUint64()
{
previous = (A * previous + C) & M;
return previous;
@ -105,16 +103,16 @@ public:
/*! Return a random integer between -2^31 and 2^31 - 1
*/
int32 randInt32()
int32_t randInt32()
{
return (int32) (randUint64() >> 16);
return (int32_t) (randUint64() >> 16);
}
/*! Return a random integer between 0 and 2^32 - 1
*/
uint32 randUint32()
uint32_t randUint32()
{
return (uint32) (randUint64() >> 16);
return (uint32_t) (randUint64() >> 16);
}
/*! Generate a random floating point value in [ 0, 1 )
@ -124,7 +122,7 @@ public:
*/
float randFloat()
{
uint32 randBits = randInt32();
uint32_t randBits = randInt32();
randBits = (randBits & 0x007fffff) | 0x3f800000;
return *reinterpret_cast<float*>(&randBits) - 1.0f;
}
@ -136,13 +134,13 @@ public:
*/
float randSfloat()
{
uint32 randBits = (uint32) (randUint64() >> 16);
uint32_t randBits = (uint32_t) (randUint64() >> 16);
randBits = (randBits & 0x007fffff) | 0x40000000;
return *reinterpret_cast<float*>(&randBits) - 3.0f;
}
private:
uint64 previous;
uint64_t previous;
};
@ -288,7 +286,7 @@ ParticleEmitter::setBlendMode(cmod::Material::BlendMode blendMode)
}
static const uint64 scrambleMask = (uint64(0xcccccccc) << 32) | 0xcccccccc;
static const uint64_t scrambleMask = (uint64_t(0xcccccccc) << 32) | 0xcccccccc;
void
ParticleEmitter::render(double tsec,
@ -394,7 +392,7 @@ ParticleEmitter::render(double tsec,
// the first particle is drawn. This would entail further restrictions,
// such as no 'branching' (variable number of calls to LCG::generate()) in
// particle state calculation.
LCGRandomGenerator gen(uint64(serial) * uint64(0x128ef719) ^ scrambleMask);
LCGRandomGenerator gen(uint64_t(serial) * uint64_t(0x128ef719) ^ scrambleMask);
// Calculate the color of the particle
// TODO: switch to using a lookup table for color and opacity
@ -454,7 +452,7 @@ ParticleEmitter::createMaterial()
}
#define STRUCT_OFFSET(s, memberName) ((uint32) (reinterpret_cast<char*>(&(s).memberName) - reinterpret_cast<char*>(&(s))))
#define STRUCT_OFFSET(s, memberName) ((uint32_t) (reinterpret_cast<char*>(&(s).memberName) - reinterpret_cast<char*>(&(s))))
ParticleSystem::ParticleSystem() :
m_vertexDesc(nullptr),

View File

@ -199,7 +199,7 @@ static const int MinSkySlices = 30;
// Size at which the orbit cache will be flushed of old orbit paths
static const unsigned int OrbitCacheCullThreshold = 200;
// Age in frames at which unused orbit paths may be eliminated from the cache
static const uint32 OrbitCacheRetireAge = 16;
static const uint32_t OrbitCacheRetireAge = 16;
Color Renderer::StarLabelColor (0.471f, 0.356f, 0.682f);
Color Renderer::PlanetLabelColor (0.407f, 0.333f, 0.964f);
@ -633,7 +633,7 @@ Renderer::Renderer() :
pointStarVertexBuffer = new PointStarVertexBuffer(2048);
glareVertexBuffer = new PointStarVertexBuffer(2048);
skyVertices = new SkyVertex[MaxSkySlices * (MaxSkyRings + 1)];
skyIndices = new uint32[(MaxSkySlices + 1) * 2 * MaxSkyRings];
skyIndices = new uint32_t[(MaxSkySlices + 1) * 2 * MaxSkyRings];
skyContour = new SkyContourPoint[MaxSkySlices + 1];
colorTemp = GetStarColorTable(ColorTable_Blackbody_D65);
#ifdef DEBUG_HDR_FILE
@ -856,8 +856,8 @@ static void RectToSphericalMapEval(float x, float y, float z,
// Pack texture coordinates in red/green and blue/alpha
// u = red + green/256
// v = blue* + alpha/256
uint16 rg = (uint16) (u * 65535.99);
uint16 ba = (uint16) (v * 65535.99);
uint16_t rg = (uint16_t) (u * 65535.99);
uint16_t ba = (uint16_t) (v * 65535.99);
pixel[0] = rg >> 8;
pixel[1] = rg & 0xff;
pixel[2] = ba >> 8;
@ -6549,7 +6549,7 @@ void Renderer::renderLocations(const Body& body,
double z = viewNormal.dot(labelPos);
labelPos *= planetZ / z;
uint32 featureType = location.getFeatureType();
uint32_t featureType = location.getFeatureType();
MarkerRepresentation* locationMarker = nullptr;
if (featureType & Location::City)
locationMarker = &cityRep;

View File

@ -682,7 +682,7 @@ class Renderer
bool useNewStarRendering;
uint32 frameCount;
uint32_t frameCount;
int currentIntervalIndex;
@ -701,29 +701,29 @@ class Renderer
struct OrbitSection
{
Capsuled boundingVolume;
uint32 firstSample;
uint32_t firstSample;
};
struct CachedOrbit
{
std::vector<OrbitSample> trajectory;
std::vector<OrbitSection> sections;
uint32 lastUsed;
uint32_t lastUsed;
};
#endif
private:
typedef std::map<const Orbit*, CurvePlot*> OrbitCache;
OrbitCache orbitCache;
uint32 lastOrbitCacheFlush;
uint32_t lastOrbitCacheFlush;
float minOrbitSize;
float distanceLimit;
float minFeatureSize;
uint32 locationFilter;
uint32_t locationFilter;
SkyVertex* skyVertices;
uint32* skyIndices;
uint32_t* skyIndices;
SkyContourPoint* skyContour;
const ColorTemperatureTable* colorTemp;

View File

@ -98,7 +98,7 @@ class ShaderProperties
// Bit 2, on if there are ring shadows
// Bit 3, on for self shadowing
// Bit 4, on for cloud shadows
uint32 shadowCounts;
uint32_t shadowCounts;
// Effects that may be applied with any light model
unsigned short effects;

View File

@ -35,7 +35,7 @@ class SolarSystem
FrameTree* frameTree;
};
typedef std::map<uint32, SolarSystem*> SolarSystemCatalog;
typedef std::map<uint32_t, SolarSystem*> SolarSystemCatalog;
class Universe;

View File

@ -14,7 +14,6 @@
#include "spheremesh.h"
#include <celmath/mathlib.h>
#include <celutil/basictypes.h>
#include <GL/glew.h>
#include <cmath>
@ -345,7 +344,7 @@ void SphereMesh::displace(DisplacementMapFunc func, void* info)
Mesh* SphereMesh::convertToMesh() const
{
uint32 stride = 32;
uint32_t stride = 32;
Mesh::VertexAttribute attributes[3];
attributes[0] = Mesh::VertexAttribute(Mesh::Position, Mesh::Float3, 0);
attributes[1] = Mesh::VertexAttribute(Mesh::Normal, Mesh::Float3, 12);
@ -359,8 +358,7 @@ Mesh* SphereMesh::convertToMesh() const
// arrays into a single array.
auto* vertexData = new char[stride * nVertices];
int i;
for (i = 0; i < nVertices; i++)
for (int i = 0; i < nVertices; i++)
{
float* vertex = reinterpret_cast<float*>(vertexData + stride * i);
vertex[0] = vertices[i * 3];
@ -375,9 +373,9 @@ Mesh* SphereMesh::convertToMesh() const
mesh->setVertices(nVertices, vertexData);
for (i = 0; i < nRings - 1; i++)
for (int i = 0; i < nRings - 1; i++)
{
uint32* indexData = new uint32[(nSlices + 1) * 2];
auto* indexData = new uint32_t[(nSlices + 1) * 2];
for (int j = 0; j <= nSlices; j++)
{
indexData[j * 2 + 0] = i * (nSlices + 1) + j;

View File

@ -441,7 +441,7 @@ StarDetails::GetNormalStarDetails(StellarClass::SpectralClass specClass,
if (subclass > StellarClass::Subclass_Unknown)
subclass = StellarClass::Subclass_Unknown;
uint index = subclass + (specClass + lumClass * StellarClass::Spectral_Count) * 11;
unsigned int index = subclass + (specClass + lumClass * StellarClass::Spectral_Count) * 11;
if (normalStarDetails[index] == nullptr)
{
char name[16];
@ -653,7 +653,7 @@ StarDetails::GetWhiteDwarfDetails(StellarClass::SpectralClass specClass,
if (subclass > StellarClass::Subclass_Unknown)
subclass = StellarClass::Subclass_Unknown;
uint index = subclass + (scIndex * StellarClass::SubclassCount);
unsigned int index = subclass + (scIndex * StellarClass::SubclassCount);
if (whiteDwarfDetails[index] == nullptr)
{
char name[16];
@ -826,14 +826,14 @@ StarDetails::setSpectralType(const std::string& s)
void
StarDetails::setKnowledge(uint32 _knowledge)
StarDetails::setKnowledge(uint32_t _knowledge)
{
knowledge = _knowledge;
}
void
StarDetails::addKnowledge(uint32 _knowledge)
StarDetails::addKnowledge(uint32_t _knowledge)
{
knowledge |= _knowledge;
}
@ -1097,7 +1097,7 @@ Star::getInfoURL() const
}
void Star::setCatalogNumber(uint32 n)
void Star::setCatalogNumber(uint32_t n)
{
catalogNumber = n;
}

View File

@ -11,7 +11,6 @@
#ifndef _CELENGINE_STAR_H_
#define _CELENGINE_STAR_H_
#include <celutil/basictypes.h>
#include <celutil/reshandle.h>
#include <celutil/color.h>
#include <celengine/univcoord.h>
@ -77,10 +76,10 @@ class StarDetails
KnowRotation = 0x2,
KnowTexture = 0x4,
};
inline uint32 getKnowledge() const;
inline bool getKnowledge(uint32) const;
void setKnowledge(uint32);
void addKnowledge(uint32);
inline uint32_t getKnowledge() const;
inline bool getKnowledge(uint32_t) const;
void setKnowledge(uint32_t);
void addKnowledge(uint32_t);
private:
void addOrbitingStar(Star*);
@ -90,7 +89,7 @@ class StarDetails
float temperature{ 0.0f };
float bolometricCorrection{ 0.0f };
uint32 knowledge{ 0 };
uint32_t knowledge{ 0 };
bool visible{ true };
char spectralType[8];
@ -176,14 +175,14 @@ StarDetails::getOrbitalRadius() const
return orbitalRadius;
}
uint32
uint32_t
StarDetails::getKnowledge() const
{
return knowledge;
}
bool
StarDetails::getKnowledge(uint32 knowledgeFlags) const
StarDetails::getKnowledge(uint32_t knowledgeFlags) const
{
return ((knowledge & knowledgeFlags) == knowledgeFlags);
}
@ -232,7 +231,7 @@ public:
inline Star();
~Star();
inline uint32 getCatalogNumber() const
inline uint32_t getCatalogNumber() const
{
return catalogNumber;
}
@ -261,7 +260,7 @@ public:
Eigen::Vector3d getVelocity(double t) const;
void setCatalogNumber(uint32);
void setCatalogNumber(uint32_t);
void setPosition(float, float, float);
void setPosition(const Eigen::Vector3f& positionLy);
void setAbsoluteMagnitude(float);
@ -288,7 +287,7 @@ public:
inline float getOrbitalRadius() const;
inline Star* getOrbitBarycenter() const;
inline bool getVisibility() const;
inline uint32 getKnowledge() const;
inline uint32_t getKnowledge() const;
inline const RotationModel* getRotationModel() const;
inline Eigen::Vector3f getEllipsoidSemiAxes() const;
const std::string& getInfoURL() const;
@ -299,7 +298,7 @@ public:
};
private:
uint32 catalogNumber;
uint32_t catalogNumber;
Eigen::Vector3f position;
float absMag;
StarDetails* details;

View File

@ -97,7 +97,7 @@ struct PtrCatalogNumberOrderingPredicate
static bool parseSimpleCatalogNumber(const string& name,
const string& prefix,
uint32* catalogNumber)
uint32_t* catalogNumber)
{
char extra[4];
if (compareIgnoringCase(name, prefix, prefix.length()) == 0)
@ -108,7 +108,7 @@ static bool parseSimpleCatalogNumber(const string& name,
// characters other than whitespace are allowed after the number.
if (sscanf(name.c_str() + prefix.length(), " %u %c", &num, extra) == 1)
{
*catalogNumber = (uint32) num;
*catalogNumber = (uint32_t) num;
return true;
}
}
@ -118,7 +118,7 @@ static bool parseSimpleCatalogNumber(const string& name,
static bool parseHIPPARCOSCatalogNumber(const string& name,
uint32* catalogNumber)
uint32_t* catalogNumber)
{
return parseSimpleCatalogNumber(name,
HIPPARCOSCatalogPrefix,
@ -127,7 +127,7 @@ static bool parseHIPPARCOSCatalogNumber(const string& name,
static bool parseHDCatalogNumber(const string& name,
uint32* catalogNumber)
uint32_t* catalogNumber)
{
return parseSimpleCatalogNumber(name,
HDCatalogPrefix,
@ -136,7 +136,7 @@ static bool parseHDCatalogNumber(const string& name,
static bool parseTychoCatalogNumber(const string& name,
uint32* catalogNumber)
uint32_t* catalogNumber)
{
if (compareIgnoringCase(name, TychoCatalogPrefix, TychoCatalogPrefix.length()) == 0)
{
@ -145,7 +145,7 @@ static bool parseTychoCatalogNumber(const string& name,
string::npos).c_str(),
" %u-%u-%u", &tyc1, &tyc2, &tyc3) == 3)
{
*catalogNumber = (uint32) (tyc3 * 1000000000 + tyc2 * 10000 + tyc1);
*catalogNumber = (uint32_t) (tyc3 * 1000000000 + tyc2 * 10000 + tyc1);
return true;
}
}
@ -155,7 +155,7 @@ static bool parseTychoCatalogNumber(const string& name,
static bool parseCelestiaCatalogNumber(const string& name,
uint32* catalogNumber)
uint32_t* catalogNumber)
{
char extra[4];
@ -164,7 +164,7 @@ static bool parseCelestiaCatalogNumber(const string& name,
unsigned int num;
if (sscanf(name.c_str(), "#%u %c", &num, extra) == 1)
{
*catalogNumber = (uint32) num;
*catalogNumber = (uint32_t) num;
return true;
}
}
@ -195,7 +195,7 @@ StarDatabase::~StarDatabase()
}
Star* StarDatabase::find(uint32 catalogNumber) const
Star* StarDatabase::find(uint32_t catalogNumber) const
{
Star refStar;
refStar.setCatalogNumber(catalogNumber);
@ -212,12 +212,12 @@ Star* StarDatabase::find(uint32 catalogNumber) const
}
uint32 StarDatabase::findCatalogNumberByName(const string& name) const
uint32_t StarDatabase::findCatalogNumberByName(const string& name) const
{
if (name.empty())
return Star::InvalidCatalogNumber;
uint32 catalogNumber = Star::InvalidCatalogNumber;
uint32_t catalogNumber = Star::InvalidCatalogNumber;
if (namesDB != nullptr)
{
@ -256,7 +256,7 @@ uint32 StarDatabase::findCatalogNumberByName(const string& name) const
Star* StarDatabase::find(const string& name) const
{
uint32 catalogNumber = findCatalogNumberByName(name);
uint32_t catalogNumber = findCatalogNumberByName(name);
if (catalogNumber != Star::InvalidCatalogNumber)
return find(catalogNumber);
else
@ -264,9 +264,9 @@ Star* StarDatabase::find(const string& name) const
}
uint32 StarDatabase::crossIndex(const Catalog catalog, const uint32 celCatalogNumber) const
uint32_t StarDatabase::crossIndex(const Catalog catalog, const uint32_t celCatalogNumber) const
{
if (static_cast<uint32>(catalog) >= crossIndexes.size())
if (static_cast<uint32_t>(catalog) >= crossIndexes.size())
return Star::InvalidCatalogNumber;
CrossIndex* xindex = crossIndexes[catalog];
@ -286,7 +286,7 @@ uint32 StarDatabase::crossIndex(const Catalog catalog, const uint32 celCatalogNu
// Return the Celestia catalog number for the star with a specified number
// in a cross index.
uint32 StarDatabase::searchCrossIndexForCatalogNumber(const Catalog catalog, const uint32 number) const
uint32_t StarDatabase::searchCrossIndexForCatalogNumber(const Catalog catalog, const uint32_t number) const
{
if (static_cast<unsigned int>(catalog) >= crossIndexes.size())
return Star::InvalidCatalogNumber;
@ -307,9 +307,9 @@ uint32 StarDatabase::searchCrossIndexForCatalogNumber(const Catalog catalog, con
}
Star* StarDatabase::searchCrossIndex(const Catalog catalog, const uint32 number) const
Star* StarDatabase::searchCrossIndex(const Catalog catalog, const uint32_t number) const
{
uint32 celCatalogNumber = searchCrossIndexForCatalogNumber(catalog, number);
uint32_t celCatalogNumber = searchCrossIndexForCatalogNumber(catalog, number);
if (celCatalogNumber != Star::InvalidCatalogNumber)
return find(celCatalogNumber);
else
@ -329,7 +329,7 @@ vector<string> StarDatabase::getCompletion(const string& name) const
}
static void catalogNumberToString(uint32 catalogNumber, char* buf, unsigned int bufSize)
static void catalogNumberToString(uint32_t catalogNumber, char* buf, unsigned int bufSize)
{
// Just return an empty string if there's any chance that the buffer is too small
if (bufSize < 20 && bufSize > 0)
@ -343,11 +343,11 @@ static void catalogNumberToString(uint32 catalogNumber, char* buf, unsigned int
}
else
{
uint32 tyc3 = catalogNumber / 1000000000;
uint32_t tyc3 = catalogNumber / 1000000000;
catalogNumber -= tyc3 * 1000000000;
uint32 tyc2 = catalogNumber / 10000;
uint32_t tyc2 = catalogNumber / 10000;
catalogNumber -= tyc2 * 10000;
uint32 tyc1 = catalogNumber;
uint32_t tyc1 = catalogNumber;
sprintf(buf, "TYC %d-%d-%d", tyc1, tyc2, tyc3);
}
}
@ -368,7 +368,7 @@ static void catalogNumberToString(uint32 catalogNumber, char* buf, unsigned int
// required as it's all wrapped in the string class.)
string StarDatabase::getStarName(const Star& star, bool i18n) const
{
uint32 catalogNumber = star.getCatalogNumber();
uint32_t catalogNumber = star.getCatalogNumber();
if (namesDB != nullptr)
{
@ -401,7 +401,7 @@ void StarDatabase::getStarName(const Star& star, char* nameBuffer, unsigned int
{
assert(bufferSize != 0);
uint32 catalogNumber = star.getCatalogNumber();
uint32_t catalogNumber = star.getCatalogNumber();
if (namesDB != nullptr)
{
@ -442,7 +442,7 @@ string StarDatabase::getStarNameList(const Star& star, const unsigned int maxNam
++count;
}
uint32 hip = catalogNumber;
uint32_t hip = catalogNumber;
if (hip != Star::InvalidCatalogNumber && hip != 0 && count < maxNames)
{
if (hip <= Star::MaxTychoCatalogNumber)
@ -451,12 +451,12 @@ string StarDatabase::getStarNameList(const Star& star, const unsigned int maxNam
starNames += " / ";
if (hip >= 1000000)
{
uint32 h = hip;
uint32 tyc3 = h / 1000000000;
uint32_t h = hip;
uint32_t tyc3 = h / 1000000000;
h -= tyc3 * 1000000000;
uint32 tyc2 = h / 10000;
uint32_t tyc2 = h / 10000;
h -= tyc2 * 10000;
uint32 tyc1 = h;
uint32_t tyc1 = h;
sprintf(numString, "TYC %u-%u-%u", tyc1, tyc2, tyc3);
starNames += numString;
@ -471,7 +471,7 @@ string StarDatabase::getStarNameList(const Star& star, const unsigned int maxNam
}
}
uint32 hd = crossIndex(StarDatabase::HenryDraper, hip);
uint32_t hd = crossIndex(StarDatabase::HenryDraper, hip);
if (count < maxNames && hd != Star::InvalidCatalogNumber)
{
if (count != 0)
@ -480,7 +480,7 @@ string StarDatabase::getStarNameList(const Star& star, const unsigned int maxNam
starNames += numString;
}
uint32 sao = crossIndex(StarDatabase::SAO, hip);
uint32_t sao = crossIndex(StarDatabase::SAO, hip);
if (count < maxNames && sao != Star::InvalidCatalogNumber)
{
if (count != 0)
@ -572,7 +572,7 @@ bool StarDatabase::loadCrossIndex(const Catalog catalog, istream& in)
// Verify the version
{
uint16 version;
uint16_t version;
in.read((char*) &version, sizeof version);
LE_TO_CPU_INT16(version, version);
if (version != 0x0100)
@ -619,7 +619,7 @@ bool StarDatabase::loadCrossIndex(const Catalog catalog, istream& in)
bool StarDatabase::loadBinary(istream& in)
{
uint32 nStarsInFile = 0;
uint32_t nStarsInFile = 0;
// Verify that the star database file has a correct header
{
@ -635,7 +635,7 @@ bool StarDatabase::loadBinary(istream& in)
// Verify the version
{
uint16 version;
uint16_t version;
in.read((char*) &version, sizeof version);
LE_TO_CPU_INT16(version, version);
if (version != 0x0100)
@ -652,10 +652,10 @@ bool StarDatabase::loadBinary(istream& in)
while (((unsigned int) nStars) < totalStars)
{
uint32 catNo = 0;
uint32_t catNo = 0;
float x = 0.0f, y = 0.0f, z = 0.0f;
int16 absMag;
uint16 spectralType;
int16_t absMag;
uint16_t spectralType;
in.read((char *) &catNo, sizeof catNo);
LE_TO_CPU_INT32(catNo, catNo);
@ -770,7 +770,7 @@ static void stcError(const Tokenizer& tok,
*/
bool StarDatabase::createStar(Star* star,
StcDisposition disposition,
uint32 catalogNumber,
uint32_t catalogNumber,
Hash* starData,
const string& path,
bool isBarycenter)
@ -949,7 +949,7 @@ bool StarDatabase::createStar(Star* star,
details->setOrbit(orbit);
// See if a barycenter was specified as well
uint32 barycenterCatNo = Star::InvalidCatalogNumber;
uint32_t barycenterCatNo = Star::InvalidCatalogNumber;
bool barycenterDefined = false;
string barycenterName;
@ -1219,10 +1219,10 @@ bool StarDatabase::load(istream& in, const string& resourcePath)
}
// Parse the catalog number; it may be omitted if a name is supplied.
uint32 catalogNumber = Star::InvalidCatalogNumber;
uint32_t catalogNumber = Star::InvalidCatalogNumber;
if (tokenizer.getTokenType() == Tokenizer::TokenNumber)
{
catalogNumber = (uint32) tokenizer.getNumberValue();
catalogNumber = (uint32_t) tokenizer.getNumberValue();
tokenizer.nextToken();
}
@ -1448,7 +1448,7 @@ void StarDatabase::buildIndexes()
* in an stc file may reference each other (barycenters). Thus, a dynamic
* structure like a map is both practical and essential.
*/
Star* StarDatabase::findWhileLoading(uint32 catalogNumber) const
Star* StarDatabase::findWhileLoading(uint32_t catalogNumber) const
{
// First check for stars loaded from the binary database
if (binFileCatalogNumberIndex != nullptr)
@ -1466,7 +1466,7 @@ Star* StarDatabase::findWhileLoading(uint32 catalogNumber) const
}
// Next check for stars loaded from an stc file
map<uint32, Star*>::const_iterator iter = stcFileCatalogNumberIndex.find(catalogNumber);
map<uint32_t, Star*>::const_iterator iter = stcFileCatalogNumberIndex.find(catalogNumber);
if (iter != stcFileCatalogNumberIndex.end())
{
return iter->second;

View File

@ -107,12 +107,12 @@ class StarDatabase
~StarDatabase();
inline Star* getStar(const uint32) const;
inline uint32 size() const;
inline Star* getStar(const uint32_t) const;
inline uint32_t size() const;
Star* find(uint32 catalogNumber) const;
Star* find(uint32_t catalogNumber) const;
Star* find(const std::string&) const;
uint32 findCatalogNumberByName(const std::string&) const;
uint32_t findCatalogNumberByName(const std::string&) const;
std::vector<std::string> getCompletion(const std::string&) const;
@ -154,12 +154,12 @@ class StarDatabase
// Not exact, but any star with a catalog number greater than this is assumed to not be
// a HIPPARCOS stars.
static const uint32 MAX_HIPPARCOS_NUMBER = 999999;
static const uint32_t MAX_HIPPARCOS_NUMBER = 999999;
struct CrossIndexEntry
{
uint32 catalogNumber;
uint32 celCatalogNumber;
uint32_t catalogNumber;
uint32_t celCatalogNumber;
bool operator<(const CrossIndexEntry&) const;
};
@ -167,9 +167,9 @@ class StarDatabase
typedef std::vector<CrossIndexEntry> CrossIndex;
bool loadCrossIndex (const Catalog, std::istream&);
uint32 searchCrossIndexForCatalogNumber(const Catalog, const uint32 number) const;
Star* searchCrossIndex(const Catalog, const uint32 number) const;
uint32 crossIndex (const Catalog, const uint32 number) const;
uint32_t searchCrossIndexForCatalogNumber(const Catalog, const uint32_t number) const;
Star* searchCrossIndex(const Catalog, const uint32_t number) const;
uint32_t crossIndex (const Catalog, const uint32_t number) const;
void finish();
@ -181,14 +181,14 @@ class StarDatabase
private:
bool createStar(Star* star,
StcDisposition disposition,
uint32 catalogNumber,
uint32_t catalogNumber,
Hash* starData,
const std::string& path,
const bool isBarycenter);
void buildOctree();
void buildIndexes();
Star* findWhileLoading(uint32 catalogNumber) const;
Star* findWhileLoading(uint32_t catalogNumber) const;
int nStars{ 0 };
@ -196,7 +196,7 @@ private:
StarNameDatabase* namesDB{ nullptr };
Star** catalogNumberIndex;
StarOctree* octreeRoot{ nullptr };
uint32 nextAutoCatalogNumber{ 0xfffffffe };
uint32_t nextAutoCatalogNumber{ 0xfffffffe };
std::vector<CrossIndex*> crossIndexes;
@ -207,23 +207,23 @@ private:
Star** binFileCatalogNumberIndex{ nullptr };
unsigned int binFileStarCount{ 0 };
// Catalog number -> star mapping for stars loaded from stc files
std::map<uint32, Star*> stcFileCatalogNumberIndex;
std::map<uint32_t, Star*> stcFileCatalogNumberIndex;
struct BarycenterUsage
{
uint32 catNo;
uint32 barycenterCatNo;
uint32_t catNo;
uint32_t barycenterCatNo;
};
std::vector<BarycenterUsage> barycenters;
};
Star* StarDatabase::getStar(const uint32 n) const
Star* StarDatabase::getStar(const uint32_t n) const
{
return stars + n;
}
uint32 StarDatabase::size() const
uint32_t StarDatabase::size() const
{
return nStars;
}

View File

@ -16,7 +16,7 @@
using namespace std;
uint32 StarNameDatabase::findCatalogNumberByName(const string& name) const
uint32_t StarNameDatabase::findCatalogNumberByName(const string& name) const
{
string priName = name;
string altName;
@ -70,7 +70,7 @@ uint32 StarNameDatabase::findCatalogNumberByName(const string& name) const
}
}
uint32 catalogNumber = getCatalogNumberByName(priName);
uint32_t catalogNumber = getCatalogNumberByName(priName);
if (catalogNumber != Star::InvalidCatalogNumber)
return catalogNumber;
@ -102,7 +102,7 @@ StarNameDatabase* StarNameDatabase::readNames(istream& in)
while (!failed)
{
uint32 catalogNumber = Star::InvalidCatalogNumber;
uint32_t catalogNumber = Star::InvalidCatalogNumber;
in >> catalogNumber;
if (in.eof())

View File

@ -23,7 +23,7 @@ class StarNameDatabase: public NameDatabase<Star>
StarNameDatabase() {};
uint32 findCatalogNumberByName(const std::string&) const;
uint32_t findCatalogNumberByName(const std::string&) const;
static StarNameDatabase* readNames(std::istream&);
};

View File

@ -141,18 +141,18 @@ string StellarClass::str() const
}
uint16
uint16_t
StellarClass::pack() const
{
return (((uint16) starType << 12) |
(((uint16) specClass & 0xf) << 8) |
((uint16) subclass << 4) |
((uint16) lumClass));
return (((uint16_t) starType << 12) |
(((uint16_t) specClass & 0xf) << 8) |
((uint16_t) subclass << 4) |
((uint16_t) lumClass));
}
bool
StellarClass::unpack(uint16 st)
StellarClass::unpack(uint16_t st)
{
starType = static_cast<StellarClass::StarType>(st >> 12);
@ -233,7 +233,7 @@ enum ParseState
StellarClass
StellarClass::parse(const string& st)
{
uint32 i = 0;
uint32_t i = 0;
ParseState state = BeginState;
StellarClass::StarType starType = StellarClass::NormalStar;
StellarClass::SpectralClass specClass = StellarClass::Spectral_Unknown;

View File

@ -12,7 +12,6 @@
#include <iostream>
#include <string>
#include <celutil/basictypes.h>
#include <celutil/color.h>
@ -104,8 +103,8 @@ public:
friend bool operator<(const StellarClass& sc0, const StellarClass& sc1);
uint16 pack() const;
bool unpack(uint16);
uint16_t pack() const;
bool unpack(uint16_t);
private:
StarType starType;

View File

@ -10,7 +10,6 @@
#ifndef _SURFACE_H_
#define _SURFACE_H_
#include <celutil/basictypes.h>
#include <celutil/color.h>
#include <celutil/reshandle.h>
#include "multitexture.h"
@ -47,7 +46,7 @@ class Surface
ApplyOverlay = 0x200,
};
uint32 appearanceFlags;
uint32_t appearanceFlags;
Color color;
Color hazeColor;
Color specularColor;

View File

@ -267,8 +267,8 @@ static void LoadMipmapSet(Image& img, GLenum target)
for (int mip = 0; mip < img.getMipLevelCount(); mip++)
{
uint mipWidth = max((uint) img.getWidth() >> mip, 1u);
uint mipHeight = max((uint) img.getHeight() >> mip, 1u);
unsigned int mipWidth = max((uint) img.getWidth() >> mip, 1u);
unsigned int mipHeight = max((uint) img.getHeight() >> mip, 1u);
if (img.isCompressed())
{
@ -599,10 +599,10 @@ TiledTexture::TiledTexture(Image& img,
int blockSize = getCompressedBlockSize(img.getFormat());
unsigned char* imgMip =
img.getMipLevel(min(mip, mipLevelCount));
uint mipWidth = max((uint) img.getWidth() >> mip, 1u);
unsigned int mipWidth = max((uint) img.getWidth() >> mip, 1u);
unsigned char* tileMip = tile->getMipLevel(mip);
uint tileMipWidth = max((uint) tile->getWidth() >> mip, 1u);
uint tileMipHeight = max((uint) tile->getHeight() >> mip, 1u);
unsigned int tileMipWidth = max((uint) tile->getWidth() >> mip, 1u);
unsigned int tileMipHeight = max((uint) tile->getHeight() >> mip, 1u);
int uBlocks = max(tileMipWidth / 4, 1u);
int vBlocks = max(tileMipHeight / 4, 1u);
int destBytesPerRow = uBlocks * blockSize;

View File

@ -11,7 +11,6 @@
#define _CELENGINE_TEXTURE_H_
#include <string>
#include <celutil/basictypes.h>
#include <celutil/color.h>
#include <celengine/image.h>

View File

@ -100,7 +100,7 @@ SolarSystem* Universe::getSolarSystem(const Star* star) const
if (star == nullptr)
return nullptr;
uint32 starNum = star->getCatalogNumber();
uint32_t starNum = star->getCatalogNumber();
auto iter = solarSystemCatalog->find(starNum);
if (iter != solarSystemCatalog->end())
return iter->second;

View File

@ -10,7 +10,6 @@
#ifndef _VERTEXBUF_H_
#define _VERTEXBUF_H_
#include <celutil/basictypes.h>
#include <celutil/color.h>
#include <celmath/vecmath.h>
#include <celmath/aabox.h>
@ -44,7 +43,7 @@ class VertexBuffer
};
public:
VertexList(uint32 _parts, uint32 initialVertexPoolSize = 0);
VertexList(uint32_t _parts, uint32_t initialVertexPoolSize = 0);
~VertexList();
void addVertex(const Vertex& v);
@ -58,11 +57,11 @@ class VertexBuffer
void transform(Vec3f translation, float scale);
private:
uint32 parts;
uint32 vertexSize;
uint32_t parts;
uint32_t vertexSize;
uint32 nVertices;
uint32 maxVertices;
uint32_t nVertices;
uint32_t maxVertices;
VertexPart* vertices;
Color diffuseColor;

View File

@ -46,7 +46,7 @@ static bool isPow2(int x)
#if 0
// Useful if we want to use a packed quadtree to store tiles instead of
// the currently implemented tree structure.
static inline uint lodOffset(uint lod)
static inline unsigned int lodOffset(unsigned int lod)
{
return ((1 << (lod << 1)) - 1) & 0xaaaaaaaa;
}
@ -95,12 +95,12 @@ const TextureTile VirtualTexture::getTile(int lod, int u, int v)
TileQuadtreeNode* node = tileTree[u >> lod];
Tile* tile = node->tile;
uint tileLOD = 0;
unsigned int tileLOD = 0;
for (int n = 0; n < lod; n++)
{
uint mask = 1 << (lod - n - 1);
uint child = (((v & mask) << 1) | (u & mask)) >> (lod - n - 1);
unsigned int mask = 1 << (lod - n - 1);
unsigned int child = (((v & mask) << 1) | (u & mask)) >> (lod - n - 1);
//int child = (((v << 1) | u) >> (lod - n - 1)) & 3;
if (!node->children[child])
break;
@ -118,8 +118,8 @@ const TextureTile VirtualTexture::getTile(int lod, int u, int v)
return TextureTile(0);
// Make the tile resident.
uint tileU = u >> (lod - tileLOD);
uint tileV = v >> (lod - tileLOD);
unsigned int tileU = u >> (lod - tileLOD);
unsigned int tileV = v >> (lod - tileLOD);
makeResident(tile, tileLOD, tileU, tileV);
// It's possible that we failed to make the tile resident, either
@ -137,7 +137,7 @@ const TextureTile VirtualTexture::getTile(int lod, int u, int v)
// If the tile came from a lower LOD than the requested one,
// we'll only use a subsection of it.
uint lodDiff = lod - tileLOD;
unsigned int lodDiff = lod - tileLOD;
texDU = texDV = 1.0f / (float) (1 << lodDiff);
texU = (u & ((1 << lodDiff) - 1)) * texDU;
texV = (v & ((1 << lodDiff) - 1)) * texDV;
@ -188,7 +188,7 @@ void VirtualTexture::endUsage()
#if 0
uint VirtualTexture::tileIndex(unsigned int lod,
unsigned int VirtualTexture::tileIndex(unsigned int lod,
unsigned int u, unsigned int v)
{
unsigned int lodBase = lodOffset(lod + baseSplit) - lodOffset(baseSplit);
@ -197,7 +197,7 @@ uint VirtualTexture::tileIndex(unsigned int lod,
#endif
ImageTexture* VirtualTexture::loadTileTexture(uint lod, uint u, uint v)
ImageTexture* VirtualTexture::loadTileTexture(unsigned int lod, unsigned int u, unsigned int v)
{
lod >>= baseSplit;
@ -231,7 +231,7 @@ ImageTexture* VirtualTexture::loadTileTexture(uint lod, uint u, uint v)
}
void VirtualTexture::makeResident(Tile* tile, uint lod, uint u, uint v)
void VirtualTexture::makeResident(Tile* tile, unsigned int lod, unsigned int u, unsigned int v)
{
if (tile->tex == nullptr && !tile->loadFailed)
{
@ -249,7 +249,7 @@ void VirtualTexture::makeResident(Tile* tile, uint lod, uint u, uint v)
void VirtualTexture::populateTileTree()
{
// Count the number of resolution levels present
uint maxLevel = 0;
unsigned int maxLevel = 0;
// Crash potential if the tile prefix contains a %, so disallow it
string pattern;
@ -292,14 +292,14 @@ void VirtualTexture::populateTileTree()
}
void VirtualTexture::addTileToTree(Tile* tile, uint lod, uint u, uint v)
void VirtualTexture::addTileToTree(Tile* tile, unsigned int lod, unsigned int u, unsigned int v)
{
TileQuadtreeNode* node = tileTree[u >> lod];
for (uint i = 0; i < lod; i++)
for (unsigned int i = 0; i < lod; i++)
{
uint mask = 1 << (lod - i - 1);
uint child = (((v & mask) << 1) | (u & mask)) >> (lod - i - 1);
unsigned int mask = 1 << (lod - i - 1);
unsigned int child = (((v & mask) << 1) | (u & mask)) >> (lod - i - 1);
if (!node->children[child])
node->children[child] = new TileQuadtreeNode();
node = node->children[child];

View File

@ -11,7 +11,6 @@
#define _CELENGINE_VIRTUALTEX_H_
#include <string>
#include "celutil/basictypes.h"
#include <celengine/texture.h>
@ -51,9 +50,9 @@ class VirtualTexture : public Texture
};
void populateTileTree();
void addTileToTree(Tile* tile, uint lod, uint u, uint v);
void makeResident(Tile* tile, uint lod, uint u, uint v);
ImageTexture* loadTileTexture(uint lod, uint u, uint v);
void addTileToTree(Tile* tile, unsigned int lod, unsigned int u, unsigned int v);
void makeResident(Tile* tile, unsigned int lod, unsigned int u, unsigned int v);
ImageTexture* loadTileTexture(unsigned int lod, unsigned int u, unsigned int v);
Tile* tiles;
Tile* findTile(unsigned int lod,

View File

@ -15,7 +15,6 @@
#include <cstdio>
#include <cassert>
#include <celutil/bytes.h>
#include <celutil/basictypes.h>
#include "jpleph.h"
using namespace Eigen;
@ -34,12 +33,12 @@ static const int LabelSize = 84;
// Read a big-endian 32-bit unsigned integer
static int32 readUint(istream& in)
static int32_t readUint(istream& in)
{
int32 ret;
in.read((char*) &ret, sizeof(int32));
int32_t ret;
in.read((char*) &ret, sizeof(int32_t));
BE_TO_CPU_INT32(ret, ret);
return (uint32) ret;
return (uint32_t) ret;
}
// Read a big-endian 64-bit IEEE double--if the native double format isn't

View File

@ -143,7 +143,7 @@ public:
// String to flag mappings
typedef std::map<std::string, uint32> FlagMap;
typedef std::map<std::string, uint32_t> FlagMap;
typedef std::map<std::string, Color*> ColorMap;
static void initMaps();

View File

@ -703,7 +703,7 @@ static int object_getinfo(lua_State* l)
celx.setTable("importance", (lua_Number)location->getImportance());
celx.setTable("infoURL", location->getInfoURL().c_str());
uint32 featureType = location->getFeatureType();
uint32_t featureType = location->getFeatureType();
string featureName("Unknown");
auto iter = std::find_if(CelxLua::LocationFlagMap.begin(),
CelxLua::LocationFlagMap.end(),
@ -943,10 +943,10 @@ static int object_catalognumber(lua_State* l)
}
}
uint32 catalogNumber = Star::InvalidCatalogNumber;
uint32_t catalogNumber = Star::InvalidCatalogNumber;
if (sel->star() != nullptr && validCatalog)
{
uint32 internalNumber = sel->star()->getCatalogNumber();
uint32_t internalNumber = sel->star()->getCatalogNumber();
if (useHIPPARCOS)
{
@ -983,7 +983,7 @@ static int object_locations_iter(lua_State* l)
}
// Get the current counter value
uint32 i = (uint32) lua_tonumber(l, lua_upvalueindex(2));
uint32_t i = (uint32_t) lua_tonumber(l, lua_upvalueindex(2));
vector<Location*>* locations = nullptr;
if (sel->body() != nullptr)
@ -1231,7 +1231,7 @@ static int object_phases_iter(lua_State* l)
}
// Get the current counter value
uint32 i = (uint32) lua_tonumber(l, lua_upvalueindex(2));
uint32_t i = (uint32_t) lua_tonumber(l, lua_upvalueindex(2));
const Timeline* timeline = nullptr;
if (sel->body() != nullptr)

View File

@ -177,8 +177,8 @@ QVariant StarTableModel::data(const QModelIndex& index, int role) const
{
case NameColumn:
{
uint32 hipCatNo = star->getCatalogNumber();
uint32 hdCatNo = universe->getStarCatalog()->crossIndex(StarDatabase::HenryDraper, hipCatNo);
uint32_t hipCatNo = star->getCatalogNumber();
uint32_t hdCatNo = universe->getStarCatalog()->crossIndex(StarDatabase::HenryDraper, hipCatNo);
if (hdCatNo != Star::InvalidCatalogNumber)
return QString("HD %1").arg(hdCatNo);
else

View File

@ -47,15 +47,15 @@ static void SetComboBoxValue(QComboBox* combo, const QVariant& value)
}
static uint32 FilterOtherLocations = ~(Location::City |
Location::Observatory |
Location::LandingSite |
Location::Mons |
Location::Mare |
Location::Crater |
Location::Vallis |
Location::Terra |
Location::EruptiveCenter);
static uint32_t FilterOtherLocations = ~(Location::City |
Location::Observatory |
Location::LandingSite |
Location::Mons |
Location::Mare |
Location::Crater |
Location::Vallis |
Location::Terra |
Location::EruptiveCenter);
PreferencesDialog::PreferencesDialog(QWidget* parent, CelestiaCore* core) :

View File

@ -13,7 +13,6 @@
#include <QDialog>
#include "ui_preferences.h"
#include <celutil/basictypes.h>
class CelestiaCore;

View File

@ -9,7 +9,6 @@
// of the License, or (at your option) any later version.
#include "modelfile.h"
#include <celutil/basictypes.h>
#include <celutil/bytes.h>
#include <cstring>
#include <cassert>
@ -1634,12 +1633,12 @@ BinaryModelLoader::reportError(const string& msg)
// Read a big-endian 32-bit unsigned integer
static int32 readUint(istream& in)
static uint32_t readUint(istream& in)
{
int32 ret;
in.read((char*) &ret, sizeof(int32));
int32_t ret;
in.read((char*) &ret, sizeof(int32_t));
LE_TO_CPU_INT32(ret, ret);
return (uint32) ret;
return (uint32_t) ret;
}
@ -1652,10 +1651,10 @@ static float readFloat(istream& in)
}
static int16 readInt16(istream& in)
static int16_t readInt16(istream& in)
{
int16 ret;
in.read((char *) &ret, sizeof(int16));
int16_t ret;
in.read((char *) &ret, sizeof(int16_t));
LE_TO_CPU_INT16(ret, ret);
return ret;
}
@ -1701,8 +1700,8 @@ static bool readTypeString(istream& in, string& s)
if (readType(in) != CMOD_String)
return false;
uint16 len;
in.read((char*) &len, sizeof(uint16));
uint16_t len;
in.read((char*) &len, sizeof(uint16_t));
LE_TO_CPU_INT16(len, len);
if (len == 0)
@ -1748,8 +1747,8 @@ static bool ignoreValue(istream& in)
break;
case CMOD_String:
{
uint16 len;
in.read((char*) &len, sizeof(uint16));
uint16_t len;
in.read((char*) &len, sizeof(uint16_t));
LE_TO_CPU_INT16(len, len);
size = len;
}
@ -1892,7 +1891,7 @@ BinaryModelLoader::loadMaterial()
case CMOD_Blend:
{
int16 blendMode = readInt16(in);
int16_t blendMode = readInt16(in);
if (blendMode < 0 || blendMode >= Material::BlendMax)
{
reportError("Bad blend mode");
@ -1905,7 +1904,7 @@ BinaryModelLoader::loadMaterial()
case CMOD_Texture:
{
int16 texType = readInt16(in);
int16_t texType = readInt16(in);
if (texType < 0 || texType >= Material::TextureSemanticMax)
{
reportError("Bad texture type");
@ -1973,7 +1972,7 @@ BinaryModelLoader::loadVertexDescription()
for (;;)
{
int16 tok = readInt16(in);
int16_t tok = readInt16(in);
if (tok == CMOD_EndVertexDesc)
{
@ -1981,7 +1980,7 @@ BinaryModelLoader::loadVertexDescription()
}
if (tok >= 0 && tok < Mesh::SemanticMax)
{
int16 fmt = readInt16(in);
int16_t fmt = readInt16(in);
if (fmt < 0 || fmt >= Mesh::FormatMax)
{
reportError("Invalid vertex attribute type");
@ -2051,7 +2050,7 @@ BinaryModelLoader::loadMesh()
for (;;)
{
int16 tok = readInt16(in);
int16_t tok = readInt16(in);
if (tok == CMOD_EndMesh)
{
@ -2069,7 +2068,7 @@ BinaryModelLoader::loadMesh()
unsigned int materialIndex = readUint(in);
unsigned int indexCount = readUint(in);
uint32* indices = new uint32[indexCount];
auto* indices = new uint32_t[indexCount];
if (indices == nullptr)
{
reportError("Not enough memory to hold indices");
@ -2079,7 +2078,7 @@ BinaryModelLoader::loadMesh()
for (unsigned int i = 0; i < indexCount; i++)
{
uint32 index = readUint(in);
uint32_t index = readUint(in);
if (index >= vertexCount)
{
reportError("Index out of range");
@ -2171,10 +2170,10 @@ BinaryModelWriter::BinaryModelWriter(ostream& _out) :
}
// Utility functions for writing binary values to a file
static void writeUint32(ostream& out, uint32 val)
static void writeUint32(ostream& out, uint32_t val)
{
LE_TO_CPU_INT32(val, val);
out.write(reinterpret_cast<char*>(&val), sizeof(uint32));
out.write(reinterpret_cast<char*>(&val), sizeof(uint32_t));
}
static void writeFloat(ostream& out, float val)
@ -2183,20 +2182,20 @@ static void writeFloat(ostream& out, float val)
out.write(reinterpret_cast<char*>(&val), sizeof(float));
}
static void writeInt16(ostream& out, int16 val)
static void writeInt16(ostream& out, int16_t val)
{
LE_TO_CPU_INT16(val, val);
out.write(reinterpret_cast<char*>(&val), sizeof(int16));
out.write(reinterpret_cast<char*>(&val), sizeof(int16_t));
}
static void writeToken(ostream& out, ModelFileToken val)
{
writeInt16(out, static_cast<int16>(val));
writeInt16(out, static_cast<int16_t>(val));
}
static void writeType(ostream& out, ModelFileType val)
{
writeInt16(out, static_cast<int16>(val));
writeInt16(out, static_cast<int16_t>(val));
}
@ -2219,7 +2218,7 @@ static void writeTypeColor(ostream& out, const Material::Color& c)
static void writeTypeString(ostream& out, const string& s)
{
writeType(out, CMOD_String);
writeInt16(out, static_cast<int16>(s.length()));
writeInt16(out, static_cast<int16_t>(s.length()));
out.write(s.c_str(), s.length());
}
@ -2242,7 +2241,7 @@ BinaryModelWriter::write(const Model& model)
void
BinaryModelWriter::writeGroup(const Mesh::PrimitiveGroup& group)
{
writeInt16(out, static_cast<int16>(group.prim));
writeInt16(out, static_cast<int16_t>(group.prim));
writeUint32(out, group.materialIndex);
writeUint32(out, group.nIndices);
@ -2329,8 +2328,8 @@ BinaryModelWriter::writeVertexDescription(const Mesh::VertexDescription& desc)
for (unsigned int attr = 0; attr < desc.nAttributes; attr++)
{
writeInt16(out, static_cast<int16>(desc.attributes[attr].semantic));
writeInt16(out, static_cast<int16>(desc.attributes[attr].format));
writeInt16(out, static_cast<int16_t>(desc.attributes[attr].semantic));
writeInt16(out, static_cast<int16_t>(desc.attributes[attr].format));
}
writeToken(out, CMOD_EndVertexDesc);
@ -2375,7 +2374,7 @@ BinaryModelWriter::writeMaterial(const Material& material)
if (material.blend != DefaultBlend)
{
writeToken(out, CMOD_Blend);
writeInt16(out, (int16) material.blend);
writeInt16(out, (int16_t) material.blend);
}
for (int i = 0; i < Material::TextureSemanticMax; i++)
@ -2386,7 +2385,7 @@ BinaryModelWriter::writeMaterial(const Material& material)
if (!texSource.empty())
{
writeToken(out, CMOD_Texture);
writeInt16(out, (int16) i);
writeInt16(out, (int16_t) i);
writeTypeString(out, texSource);
}
}

View File

@ -277,45 +277,45 @@ void TextureFont::rebuildGlyphLookupTable()
}
static uint32 readUint32(istream& in, bool swap)
static uint32_t readUint32(istream& in, bool swap)
{
uint32 x;
uint32_t x;
in.read(reinterpret_cast<char*>(&x), sizeof x);
return swap ? bswap_32(x) : x;
}
static uint16 readUint16(istream& in, bool swap)
static uint16_t readUint16(istream& in, bool swap)
{
uint16 x;
uint16_t x;
in.read(reinterpret_cast<char*>(&x), sizeof x);
return swap ? bswap_16(x) : x;
}
static uint8 readUint8(istream& in)
static uint8_t readUint8(istream& in)
{
uint8 x;
uint8_t x;
in.read(reinterpret_cast<char*>(&x), sizeof x);
return x;
}
/* Not currently used
static int32 readInt32(istream& in, bool swap)
static int32_t readInt32(istream& in, bool swap)
{
int32 x;
int32_t x;
in.read(reinterpret_cast<char*>(&x), sizeof x);
return swap ? static_cast<int32>(bswap_32(static_cast<uint32>(x))) : x;
return swap ? static_cast<int32_t>(bswap_32(static_cast<uint32_t>(x))) : x;
}*/
static int16 readInt16(istream& in, bool swap)
static int16_t readInt16(istream& in, bool swap)
{
int16 x;
int16_t x;
in.read(reinterpret_cast<char*>(&x), sizeof x);
return swap ? static_cast<int16>(bswap_16(static_cast<uint16>(x))) : x;
return swap ? static_cast<int16_t>(bswap_16(static_cast<uint16_t>(x))) : x;
}
static int8 readInt8(istream& in)
static int8_t readInt8(istream& in)
{
int8 x;
int8_t x;
in.read(reinterpret_cast<char*>(&x), sizeof x);
return x;
}
@ -332,7 +332,7 @@ TextureFont* TextureFont::load(istream& in)
return nullptr;
}
uint32 endiannessTest = 0;
uint32_t endiannessTest = 0;
in.read(reinterpret_cast<char*>(&endiannessTest), sizeof endiannessTest);
if (!in.good())
{
@ -377,7 +377,7 @@ TextureFont* TextureFont::load(istream& in)
for (unsigned int i = 0; i < nGlyphs; i++)
{
uint16 __id = readUint16(in, byteSwap);
uint16_t __id = readUint16(in, byteSwap);
TextureFont::Glyph glyph(__id);
glyph.width = readUint8(in);

View File

@ -13,7 +13,6 @@
#include <vector>
#include <string>
#include <iostream>
#include <celutil/basictypes.h>
class TextureFont

View File

@ -1,43 +0,0 @@
// basictypes.h
//
// Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
#ifndef _BASICTYPES_H_
#define _BASICTYPES_H_
typedef unsigned int uint;
// Fixed size types
typedef int int32;
typedef unsigned int uint32;
typedef short int16;
typedef unsigned short uint16;
typedef char int8;
typedef unsigned char uint8;
#ifdef _MSC_VER
// MS Visual C++ does not include stdint.h
typedef __int64 int64;
typedef unsigned __int64 uint64;
#else
#include <stdint.h>
#include <limits>
typedef int64_t int64;
typedef uint64_t uint64;
#ifndef INT64_MAX
#define INT64_MAX 9223372036854775807LL
#endif
#ifndef UINT64_MAX
#define UINT64_MAX 0xffffffffffffffffULL
#endif
//#define INT64_MAX std::numeric_limits<int64_t>::max()
//#define UINT64_MAX std::numeric_limits<uint64_t>::max()
#endif
#endif // _BASICTYPES_H_

View File

@ -29,22 +29,6 @@ static const double WORD3_FACTOR = POW2_32;
/*** Constructors ***/
/*
// Compute the additive inverse of a 128-bit twos complement value
// represented by two 64-bit values.
inline void negate128(uint64& hi, uint64& lo)
{
// For a twos-complement number, -n = ~n + 1
hi = ~hi;
lo = ~lo;
lo++;
if (lo == 0)
hi++;
}
*/
// Create a BigFix initialized to zero
BigFix::BigFix()
{
@ -53,7 +37,7 @@ BigFix::BigFix()
}
BigFix::BigFix(uint64 i)
BigFix::BigFix(uint64_t i)
{
hi = i;
lo = 0;
@ -77,16 +61,16 @@ BigFix::BigFix(double d)
double e = floor(d * (1.0 / WORD3_FACTOR));
if (e < POW2_31)
{
auto w3 = (uint32) e;
auto w3 = (uint32_t) e;
d -= w3 * WORD3_FACTOR;
auto w2 = (uint32) (d * (1.0 / WORD2_FACTOR));
auto w2 = (uint32_t) (d * (1.0 / WORD2_FACTOR));
d -= w2 * WORD2_FACTOR;
auto w1 = (uint32) (d * (1.0 / WORD1_FACTOR));
auto w1 = (uint32_t) (d * (1.0 / WORD1_FACTOR));
d -= w1 * WORD1_FACTOR;
auto w0 = (uint32) (d * (1.0 / WORD0_FACTOR));
auto w0 = (uint32_t) (d * (1.0 / WORD0_FACTOR));
hi = ((uint64) w3 << 32) | w2;
lo = ((uint64) w1 << 32) | w0;
hi = ((uint64_t) w3 << 32) | w2;
lo = ((uint64_t) w1 << 32) | w0;
if (isNegative)
negate128(hi, lo);
@ -106,8 +90,8 @@ BigFix::operator double() const
// Handle negative values by inverting them before conversion,
// then inverting the converted value.
int sign = 1;
uint64 l = lo;
uint64 h = hi;
uint64_t l = lo;
uint64_t h = hi;
if (isNegative())
{
@ -117,10 +101,10 @@ BigFix::operator double() const
// Need to break the number into 32-bit chunks because a 64-bit
// integer has more bits of precision than a double.
uint32 w0 = l & 0xffffffff;
uint32 w1 = l >> 32;
uint32 w2 = h & 0xffffffff;
uint32 w3 = h >> 32;
uint32_t w0 = l & 0xffffffff;
uint32_t w1 = l >> 32;
uint32_t w2 = h & 0xffffffff;
uint32_t w3 = h >> 32;
double d;
d = (w0 * WORD0_FACTOR +
@ -172,10 +156,10 @@ BigFix operator*(BigFix f, double d)
{
// Need to break the number into 32-bit chunks because a 64-bit
// integer has more bits of precision than a double.
uint32 w0 = f.lo & 0xffffffff;
uint32 w1 = f.lo >> 32;
uint32 w2 = f.hi & 0xffffffff;
uint32 w3 = f.hi >> 32;
uint32_t w0 = f.lo & 0xffffffff;
uint32_t w1 = f.lo >> 32;
uint32_t w2 = f.hi & 0xffffffff;
uint32_t w3 = f.hi >> 32;
return BigFix(w0 * d * WORD0_FACTOR) +
BigFix(w1 * d * WORD1_FACTOR) +
@ -192,25 +176,25 @@ BigFix operator*(const BigFix& a, const BigFix& b)
{
// Multiply two fixed point values together using partial products.
uint64 ah = a.hi;
uint64 al = a.lo;
uint64_t ah = a.hi;
uint64_t al = a.lo;
if (a.isNegative())
BigFix::negate128(ah, al);
uint64 bh = b.hi;
uint64 bl = b.lo;
uint64_t bh = b.hi;
uint64_t bl = b.lo;
if (b.isNegative())
BigFix::negate128(bh, bl);
// Break the values down into 32-bit words so that the partial products
// will fit into 64-bit words.
uint64 aw[4];
uint64_t aw[4];
aw[0] = al & 0xffffffff;
aw[1] = al >> 32;
aw[2] = ah & 0xffffffff;
aw[3] = ah >> 32;
uint64 bw[4];
uint64_t bw[4];
bw[0] = bl & 0xffffffff;
bw[1] = bl >> 32;
bw[2] = bh & 0xffffffff;
@ -219,34 +203,30 @@ BigFix operator*(const BigFix& a, const BigFix& b)
// Set the high and low non-zero words; this will
// speed up multiplicatoin of integers and values
// less than one.
unsigned int hiworda = ah == 0 ? 1 : 3;
unsigned int loworda = al == 0 ? 2 : 0;
unsigned int hiwordb = bh == 0 ? 1 : 3;
unsigned int lowordb = bl == 0 ? 2 : 0;
uint32_t hiworda = ah == 0 ? 1 : 3;
uint32_t loworda = al == 0 ? 2 : 0;
uint32_t hiwordb = bh == 0 ? 1 : 3;
uint32_t lowordb = bl == 0 ? 2 : 0;
uint32 result[8];
uint32_t result[8] = {0};
unsigned int i;
for (i = 0; i < 8; i++)
result[i] = 0;
for (i = lowordb; i <= hiwordb; i++)
for (uint32_t i = lowordb; i <= hiwordb; i++)
{
uint32 carry = 0;
uint32_t carry = 0;
unsigned int j;
for (j = loworda; j <= hiworda; j++)
{
uint64 partialProd = aw[j] * bw[i];
uint64_t partialProd = aw[j] * bw[i];
// This sum will never overflow. Let N = 2^32;
// the max value of the partial product is (N-1)^2.
// The max values of result[i + j] and carry are
// N-1. Thus the max value of the sum is
// (N-1)^2 + 2(N-1) = (N^2 - 2N + 1) + 2(N-1) = N^2-1
uint64 q = (uint64) result[i + j] + partialProd + (uint64) carry;
carry = (uint32) (q >> 32);
result[i + j] = (uint32) (q & 0xffffffff);
uint64_t q = (uint64_t) result[i + j] + partialProd + (uint64_t) carry;
carry = (uint32_t) (q >> 32);
result[i + j] = (uint32_t) (q & 0xffffffff);
}
result[i + j] = carry;
@ -255,8 +235,8 @@ BigFix operator*(const BigFix& a, const BigFix& b)
// TODO: check for overflow
// (as simple as result[0] != 0 || result[1] != 0 || highbit(result[2]))
BigFix c;
c.lo = (uint64) result[2] + ((uint64) result[3] << 32);
c.hi = (uint64) result[4] + ((uint64) result[5] << 32);
c.lo = (uint64_t) result[2] + ((uint64_t) result[3] << 32);
c.hi = (uint64_t) result[4] + ((uint64_t) result[5] << 32);
bool resultNegative = a.isNegative() != b.isNegative();
return resultNegative ? -c : c;
@ -268,10 +248,7 @@ int BigFix::sign() const
if (hi == 0 && lo == 0)
return 0;
if (hi > INT64_MAX)
return -1;
else
return 1;
return isNegative() ? -1 : 1;
}
@ -279,10 +256,10 @@ int BigFix::sign() const
void BigFix::dump()
{
printf("%08x %08x %08x %08x",
(uint32) (hi >> 32),
(uint32) (hi & 0xffffffff),
(uint32) (lo >> 32),
(uint32) (lo & 0xffffffff));
(uint32_t) (hi >> 32),
(uint32_t) (hi & 0xffffffff),
(uint32_t) (lo >> 32),
(uint32_t) (lo & 0xffffffff));
}
@ -314,7 +291,7 @@ static unsigned char alphabet[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopq
BigFix::BigFix(const std::string& val)
{
static char inalphabet[256] = {0}, decoder[256] = {0};
int i, bits, c, char_count;
int i, bits, char_count;
for (i = (sizeof alphabet) - 1; i >= 0 ; i--)
{
@ -322,23 +299,20 @@ BigFix::BigFix(const std::string& val)
decoder[alphabet[i]] = i;
}
uint16 n[8];
uint16_t n[8] = {0};
// Code from original BigFix class to convert base64 string into
// array of 8 16-bit values.
for (i = 0; i < 8 ; i++)
n[i] = 0;
char_count = 0;
bits = 0;
i = 0;
for (char c : val)
for (unsigned char c : val)
{
if (c == '=')
break;
if (c > 255 || (inalphabet[c] == 0))
if (!inalphabet[c])
continue;
bits += decoder[c];
char_count++;
@ -383,14 +357,14 @@ BigFix::BigFix(const std::string& val)
n[i/2] >>= 8;
// Now, convert the 8 16-bit values to a 2 64-bit values
lo = ((uint64) n[0] |
((uint64) n[1] << 16) |
((uint64) n[2] << 32) |
((uint64) n[3] << 48));
hi = ((uint64) n[4] |
((uint64) n[5] << 16) |
((uint64) n[6] << 32) |
((uint64) n[7] << 48));
lo = ((uint64_t) n[0] |
((uint64_t) n[1] << 16) |
((uint64_t) n[2] << 32) |
((uint64_t) n[3] << 48));
hi = ((uint64_t) n[4] |
((uint64_t) n[5] << 16) |
((uint64_t) n[6] << 32) |
((uint64_t) n[7] << 48));
}
@ -400,7 +374,7 @@ std::string BigFix::toString()
// is copied from that class, so first we'll convert from two
// 64-bit words to 8 16-bit words so that the old code can work
// as-is.
unsigned short n[8];
uint16_t n[8];
n[0] = lo & 0xffff;
n[1] = (lo >> 16) & 0xffff;
@ -414,7 +388,7 @@ std::string BigFix::toString()
// Conversion using code from the original BigFix class.
std::string encoded;
int bits, c, char_count, i, j;
int bits, c, char_count, i;
char_count = 0;
bits = 0;
@ -432,13 +406,11 @@ std::string BigFix::toString()
return encoded;
// Then we encode starting by the LSB (i+1 bytes to encode)
j = 0;
while (j <= i)
for (auto j = 0; j <= i; j++)
{
c = n[j/2];
if ( (j & 1) != 0 ) c >>= 8;
c &= 0xff;
j++;
bits += c;
char_count++;
if (char_count == 3)

View File

@ -16,7 +16,7 @@
#define _CELUTIL_BIGFIX64_H_
#include <string>
#include "basictypes.h"
#include <limits>
/*! 64.64 signed fixed point numbers.
*/
@ -25,7 +25,7 @@ class BigFix
{
public:
BigFix();
BigFix(uint64);
BigFix(uint64_t);
BigFix(double);
BigFix(const std::string&);
@ -54,20 +54,20 @@ class BigFix
private:
bool isNegative() const
{
return hi > INT64_MAX;
return hi > std::numeric_limits<int64_t>::max();
}
static void negate128(uint64& hi, uint64& lo);
static void negate128(uint64_t& hi, uint64_t& lo);
private:
uint64 hi;
uint64 lo;
uint64_t hi;
uint64_t lo;
};
// Compute the additive inverse of a 128-bit twos complement value
// represented by two 64-bit values.
inline void BigFix::negate128(uint64& hi, uint64& lo)
inline void BigFix::negate128(uint64_t& hi, uint64_t& lo)
{
// For a twos-complement number, -n = ~n + 1
hi = ~hi;

View File

@ -14,7 +14,6 @@
#define PI 3.1415926535898
#include "basictypes.h"
#include "stellarclass.h"
#include "star.h"
@ -26,10 +25,10 @@ int main(int argc, char *argv[])
float brightest = 100000;
while (nStars < MAX_STARS) {
uint32 catNo = 0;
uint32_t catNo = 0;
float RA = 0, dec = 0, parallax = 0;
int16 appMag;
uint16 stellarClass;
int16_t appMag;
uint16_t stellarClass;
cin.read((void *) &catNo, sizeof catNo);
cin.read((void *) &RA, sizeof RA);

View File

@ -15,7 +15,6 @@
#include <cmath>
#include <algorithm>
#include <map>
#include <celutil/basictypes.h>
#include <celmath/vecmath.h>
#include <celmath/mathlib.h>
#include <celmath/ray.h>
@ -103,14 +102,14 @@ Color operator*(const Color& a, const Vec3d& v)
}
static uint8 floatToByte(float f)
static uint8_t floatToByte(float f)
{
if (f <= 0.0f)
return 0;
if (f >= 1.0f)
return 255;
else
return (uint8) (f * 255.99f);
return (uint8_t)_t (f * 255.99f);
}
@ -316,7 +315,7 @@ public:
height(h),
pixels(nullptr)
{
pixels = new uint8[width * height * 3];
pixels = new uint8_t[_twidth * height * 3];
}
~RGBImage()
@ -331,9 +330,9 @@ public:
unsigned int h)
{
uint8 r = floatToByte(color.r);
uint8 g = floatToByte(color.g);
uint8 b = floatToByte(color.b);
uint8_t r = floatToByte(color.r);
uint8_t g = floatToByte(color.g);
uint8_t b = floatToByte(color.b);
for (unsigned int i = y; i < y + h; i++)
{
for (unsigned int j = x; j < x + w; j++)

View File

@ -538,19 +538,16 @@ bool parseCommandLine(int argc, char* argv[])
}
using uint32 = unsigned int;
using uint16 = unsigned short;
union Uint16
{
char bytes[2];
uint16 u;
uint16_t u;
};
union Uint32
{
char bytes[4];
uint32 u;
uint32_t u;
};
union Float
@ -562,19 +559,19 @@ union Float
union FloatInt
{
float f;
uint32 u;
uint32_t u;
};
// Convert a single precision floating point value to half precision
uint16 floatToHalf(float f)
uint16_t floatToHalf(float f)
{
FloatInt fi;
fi.f = f;
uint16 half = 0;
uint16_t half = 0;
auto signBit = uint16((fi.u & 0x80000000) >> 16);
auto signBit = uint16_t((fi.u & 0x80000000) >> 16);
if (f > 65504.0f)
{
@ -588,7 +585,7 @@ uint16 floatToHalf(float f)
}
int exponent = int((fi.u >> 23) & 0xff) - 127 + 15;
uint32 significand = fi.u & 0x007fffff;
uint32_t significand = fi.u & 0x007fffff;
if (exponent < -9)
{
@ -613,7 +610,7 @@ uint16 floatToHalf(float f)
// NaN - preserve bits, but make sure that we don't
// make the significand zero, as that would indicate
// an infinity, not a NaN
auto nanBits = uint16(significand >> 13);
auto nanBits = uint16_t(significand >> 13);
if (nanBits == 0)
{
nanBits = 1;
@ -639,14 +636,14 @@ struct DDSPixelFormat
{
DDSPixelFormat() = default;
uint32 dwSize{0};
uint32 dwFlags{0};
uint32 dwFourCC{0};
uint32 dwRGBBitCount{0};
uint32 dwRBitMask{0};
uint32 dwGBitMask{0};
uint32 dwBBitMask{0};
uint32 dwABitMask{0};
uint32_t dwSize{0};
uint32_t dwFlags{0};
uint32_t dwFourCC{0};
uint32_t dwRGBBitCount{0};
uint32_t dwRBitMask{0};
uint32_t dwGBitMask{0};
uint32_t dwBBitMask{0};
uint32_t dwABitMask{0};
};
@ -661,77 +658,77 @@ struct DDSHeader
}
}
static const uint32 CAPS_COMPLEX = 0x000008;
static const uint32 CAPS_MIPMAP = 0x400000;
static const uint32 CAPS_TEXTURE = 0x001000;
static const uint32_t CAPS_COMPLEX = 0x000008;
static const uint32_t CAPS_MIPMAP = 0x400000;
static const uint32_t CAPS_TEXTURE = 0x001000;
static const uint32 CAPS2_VOLUME = 0x200000;
static const uint32 CAPS2_CUBEMAP = 0x00000200;
static const uint32 CAPS2_CUBEMAP_POSITIVEX = 0x00000400;
static const uint32 CAPS2_CUBEMAP_NEGATIVEX = 0x00000800;
static const uint32 CAPS2_CUBEMAP_POSITIVEY = 0x00001000;
static const uint32 CAPS2_CUBEMAP_NEGATIVEY = 0x00002000;
static const uint32 CAPS2_CUBEMAP_POSITIVEZ = 0x00004000;
static const uint32 CAPS2_CUBEMAP_NEGATIVEZ = 0x00008000;
static const uint32_t CAPS2_VOLUME = 0x200000;
static const uint32_t CAPS2_CUBEMAP = 0x00000200;
static const uint32_t CAPS2_CUBEMAP_POSITIVEX = 0x00000400;
static const uint32_t CAPS2_CUBEMAP_NEGATIVEX = 0x00000800;
static const uint32_t CAPS2_CUBEMAP_POSITIVEY = 0x00001000;
static const uint32_t CAPS2_CUBEMAP_NEGATIVEY = 0x00002000;
static const uint32_t CAPS2_CUBEMAP_POSITIVEZ = 0x00004000;
static const uint32_t CAPS2_CUBEMAP_NEGATIVEZ = 0x00008000;
static const uint32 DDSD_CAPS = 0x1;
static const uint32 DDSD_HEIGHT = 0x2;
static const uint32 DDSD_WIDTH = 0x4;
static const uint32 DDSD_PITCH = 0x8;
static const uint32 DDSD_PIXELFORMAT = 0x1000;
static const uint32 DDSD_MIPMAPCOUNT = 0x20000;
static const uint32 DDSD_LINEARSIZE = 0x80000;
static const uint32 DDSD_DEPTH = 0x800000;
static const uint32_t DDSD_CAPS = 0x1;
static const uint32_t DDSD_HEIGHT = 0x2;
static const uint32_t DDSD_WIDTH = 0x4;
static const uint32_t DDSD_PITCH = 0x8;
static const uint32_t DDSD_PIXELFORMAT = 0x1000;
static const uint32_t DDSD_MIPMAPCOUNT = 0x20000;
static const uint32_t DDSD_LINEARSIZE = 0x80000;
static const uint32_t DDSD_DEPTH = 0x800000;
static const uint32 D3DFMT_A16B16G16R16 = 36;
static const uint32 D3DFMT_A16B16G16R16F = 113;
static const uint32 D3DFMT_DXT1 = 0x31545844;
static const uint32 D3DFMT_DXT3 = 0x33545844;
static const uint32 D3DFMT_DXT5 = 0x35545844;
static const uint32_t D3DFMT_A16B16G16R16 = 36;
static const uint32_t D3DFMT_A16B16G16R16F = 113;
static const uint32_t D3DFMT_DXT1 = 0x31545844;
static const uint32_t D3DFMT_DXT3 = 0x33545844;
static const uint32_t D3DFMT_DXT5 = 0x35545844;
static const uint32 FOURCC = 0x04;
static const uint32_t FOURCC = 0x04;
uint32 dwSize{sizeof(DDSHeader)};
uint32 dwFlags{DDSD_PIXELFORMAT};
uint32 dwHeight{0};
uint32 dwWidth{0};
uint32 dwLinearSize{0};
uint32 dwDepth{0};
uint32 dwMipMapCount{0};
uint32 dwReserved1[11];
uint32_t dwSize{sizeof(DDSHeader)};
uint32_t dwFlags{DDSD_PIXELFORMAT};
uint32_t dwHeight{0};
uint32_t dwWidth{0};
uint32_t dwLinearSize{0};
uint32_t dwDepth{0};
uint32_t dwMipMapCount{0};
uint32_t dwReserved1[11];
DDSPixelFormat ddpf;
uint32 dwCaps{0};
uint32 dwCaps2{0};
uint32 dwCaps3{0};
uint32 dwCaps4{0};
uint32 dwReserved2{0};
uint32_t dwCaps{0};
uint32_t dwCaps2{0};
uint32_t dwCaps3{0};
uint32_t dwCaps4{0};
uint32_t dwReserved2{0};
void setTexture()
{
dwCaps |= CAPS_TEXTURE;
}
void setFourCC(uint32 fcc)
void setFourCC(uint32_t fcc)
{
dwFlags |= FOURCC;
ddpf.dwFourCC = fcc;
}
void setMipMapLevels(uint32 levels)
void setMipMapLevels(uint32_t levels)
{
dwCaps |= (CAPS_COMPLEX | CAPS_MIPMAP);
dwFlags |= DDSD_MIPMAPCOUNT;
dwMipMapCount = levels;
}
void setDimensions(uint32 width, uint32 height)
void setDimensions(uint32_t width, uint32_t height)
{
dwFlags |= (DDSD_WIDTH | DDSD_HEIGHT);
dwWidth = width;
dwHeight = height;
}
void setVolumeDimensions(uint32 width, uint32 height, uint32 depth)
void setVolumeDimensions(uint32_t width, uint32_t height, uint32_t depth)
{
dwCaps |= CAPS_COMPLEX;
dwFlags |= (DDSD_WIDTH | DDSD_HEIGHT | DDSD_DEPTH);
@ -744,18 +741,18 @@ struct DDSHeader
static bool ByteSwapRequired = false;
static bool IsLittleEndian()
{
Uint32 endiannessTest;
Uint32_t endiannessTest;
endiannessTest.u = 0x01020304;
return endiannessTest.bytes[0] == 0x04;
}
// Write out a 16-bit unsigned integer in little-endian order
static void WriteUint16(ostream& out, uint16 u)
static void WriteUint16(ostream& out, uint16_t u)
{
static_assert(sizeof(u) == 2, "");
Uint16 ub;
Uint16_t ub;
ub.u = u;
if (ByteSwapRequired)
{
@ -767,11 +764,11 @@ static void WriteUint16(ostream& out, uint16 u)
// Write out a 32-bit unsigned integer in little-endian order
static void WriteUint32(ostream& out, uint32 u)
static void WriteUint32(ostream& out, uint32_t u)
{
static_assert(sizeof(u) == 4, "");
Uint32 ub;
Uint32_t ub;
ub.u = u;
if (ByteSwapRequired)
{

View File

@ -27,8 +27,8 @@ static string OrbitalDatabase("hip_dm_o.dat");
static const int HipStarRecordLength = 451;
static const int HipComponentRecordLength = 239;
static uint32 NullCCDMIdentifier = 0xffffffff;
static uint32 NullCatalogNumber = 0xffffffff;
static uint32_t NullCCDMIdentifier = 0xffffffff;
static uint32_t NullCatalogNumber = 0xffffffff;
class HipparcosStar
@ -38,18 +38,18 @@ public:
void write(ostream& /*out*/);
uint32 HIPCatalogNumber{};
uint32 HDCatalogNumber{};
uint32_t HIPCatalogNumber{};
uint32_t HDCatalogNumber{};
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{};
uint32_t CCDMIdentifier{};
uint8_t starsWithCCDM{};
uint8_t nComponents{};
uint8_t parallaxError{};
};
HipparcosStar::HipparcosStar() :
@ -102,7 +102,7 @@ struct HIPCatalogComparePredicate
return star0->HIPCatalogNumber < star1->HIPCatalogNumber;
}
bool operator()(const HipparcosStar* star0, uint32 hip)
bool operator()(const HipparcosStar* star0, uint32_t hip)
{
return star0->HIPCatalogNumber < hip;
}
@ -149,11 +149,11 @@ vector<HipparcosStar> companions;
vector<HipparcosComponent> components;
vector<HipparcosStar*> starIndex;
typedef map<uint32, MultistarSystem*> MultistarSystemCatalog;
typedef map<uint32_t, MultistarSystem*> MultistarSystemCatalog;
MultistarSystemCatalog starSystems;
HipparcosStar* findStar(uint32 hip)
HipparcosStar* findStar(uint32_t hip)
{
HIPCatalogComparePredicate pred;
@ -382,18 +382,18 @@ bool ReadStarRecord(istream& in)
int n = 1;
sscanf(buf + 340, "%d", &n);
star.starsWithCCDM = (uint8) n;
star.starsWithCCDM = (uint8_t) n;
sscanf(buf + 343, "%d", &n);
star.nComponents = (uint8) n;
star.nComponents = (uint8_t) n;
}
float parallaxError = 0.0f;
if (sscanf(buf + 119, "%f", &parallaxError) != 0)
{
if (star.parallax < 0.0f || parallaxError / star.parallax > 1.0f)
star.parallaxError = (int8) 255;
star.parallaxError = (int8_t) 255;
else
star.parallaxError = (int8) (parallaxError / star.parallax * 200);
star.parallaxError = (int8_t) (parallaxError / star.parallax * 200);
}
stars.insert(stars.end(), star);
@ -409,7 +409,7 @@ bool ReadComponentRecord(istream& in)
in.read(buf, HipComponentRecordLength);
uint32 hip;
uint32_t hip;
if (sscanf(buf + 42, "%ud", &hip) != 1)
{
cout << "Missing HIP catalog number for component.\n";

View File

@ -79,10 +79,10 @@ int main(int argc, char* argv[])
#if 0
// Print information about primitive groups
for (uint32 i = 0; model->getMesh(i); i++)
for (uint32_t i = 0; model->getMesh(i); i++)
{
const Mesh* mesh = model->getMesh(i);
for (uint32 j = 0; mesh->getGroup(j); j++)
for (uint32_t j = 0; mesh->getGroup(j); j++)
{
const Mesh::PrimitiveGroup* group = mesh->getGroup(j);
}

View File

@ -40,7 +40,6 @@ CELUTIL_SOURCES = \
../../../celutil/debug.cpp
CELUTIL_HEADERS = \
../../../celutil/basictypes.h \
../../../celutil/bytes.h \
../../../celutil/debug.h
@ -84,4 +83,4 @@ win32-msvc* {
win32 {
DEFINES += NOMINMAX
}
}

View File

@ -10,7 +10,6 @@
// Perform various adjustments to a cmod file
#include <celmodel/modelfile.h>
#include <celutil/basictypes.h>
#include <celmath/mathlib.h>
#include <Eigen/Core>
#include <fstream>
@ -63,10 +62,10 @@ struct Vertex
Vertex() :
index(0), attributes(nullptr) {};
Vertex(uint32 _index, const void* _attributes) :
Vertex(uint32_t _index, const void* _attributes) :
index(_index), attributes(_attributes) {};
uint32 index;
uint32_t index;
const void* attributes;
};
@ -74,8 +73,8 @@ struct Vertex
struct Face
{
Vector3f normal;
uint32 i[3]; // vertex attribute indices
uint32 vi[3]; // vertex point indices -- same as above unless welding
uint32_t i[3]; // vertex attribute indices
uint32_t vi[3]; // vertex point indices -- same as above unless welding
};
@ -156,8 +155,8 @@ private:
class PointTexCoordOrderingPredicate : public VertexComparator
{
public:
PointTexCoordOrderingPredicate(uint32 _posOffset,
uint32 _texCoordOffset,
PointTexCoordOrderingPredicate(uint32_t _posOffset,
uint32_t _texCoordOffset,
bool _wrap) :
posOffset(_posOffset),
texCoordOffset(_texCoordOffset),
@ -215,8 +214,8 @@ public:
}
private:
uint32 posOffset;
uint32 texCoordOffset;
uint32_t posOffset;
uint32_t texCoordOffset;
bool wrap;
};
@ -230,7 +229,7 @@ bool approxEqual(float x, float y, float prec)
class PointEquivalencePredicate : public VertexComparator
{
public:
PointEquivalencePredicate(uint32 _posOffset,
PointEquivalencePredicate(uint32_t _posOffset,
float _tolerance) :
posOffset(_posOffset),
tolerance(_tolerance)
@ -250,7 +249,7 @@ public:
}
private:
uint32 posOffset;
uint32_t posOffset;
float tolerance;
};
@ -258,8 +257,8 @@ private:
class PointTexCoordEquivalencePredicate : public VertexComparator
{
public:
PointTexCoordEquivalencePredicate(uint32 _posOffset,
uint32 _texCoordOffset,
PointTexCoordEquivalencePredicate(uint32_t _posOffset,
uint32_t _texCoordOffset,
bool _wrap,
float _tolerance) :
posOffset(_posOffset),
@ -286,19 +285,19 @@ public:
}
private:
uint32 posOffset;
uint32 texCoordOffset;
uint32_t posOffset;
uint32_t texCoordOffset;
bool wrap;
float tolerance;
};
bool equal(const Vertex& a, const Vertex& b, uint32 vertexSize)
bool equal(const Vertex& a, const Vertex& b, uint32_t vertexSize)
{
const auto* s0 = reinterpret_cast<const char*>(a.attributes);
const auto* s1 = reinterpret_cast<const char*>(b.attributes);
for (uint32 i = 0; i < vertexSize; i++)
for (uint32_t i = 0; i < vertexSize; i++)
{
if (s0[i] != s1[i])
return false;
@ -355,7 +354,7 @@ bool operator==(const Mesh::VertexDescription& a,
if (a.stride != b.stride || a.nAttributes != b.nAttributes)
return false;
for (uint32 i = 0; i < a.nAttributes; i++)
for (uint32_t i = 0; i < a.nAttributes; i++)
{
if (!(a.attributes[i] == b.attributes[i]))
return false;
@ -378,7 +377,7 @@ bool operator<(const Mesh::VertexDescription& a,
if (b.nAttributes < b.nAttributes)
return false;
for (uint32 i = 0; i < a.nAttributes; i++)
for (uint32_t i = 0; i < a.nAttributes; i++)
{
if (a.attributes[i] < b.attributes[i])
return true;
@ -409,7 +408,7 @@ private:
bool uniquifyVertices(Mesh& mesh)
{
uint32 nVertices = mesh.getVertexCount();
uint32_t nVertices = mesh.getVertexCount();
const Mesh::VertexDescription& desc = mesh.getVertexDescription();
if (nVertices == 0)
@ -421,7 +420,7 @@ bool uniquifyVertices(Mesh& mesh)
// Initialize the array of vertices
vector<Vertex> vertices(nVertices);
uint32 i;
uint32_t i;
for (i = 0; i < nVertices; i++)
{
vertices[i] = Vertex(i, vertexData + i * desc.stride);
@ -431,7 +430,7 @@ bool uniquifyVertices(Mesh& mesh)
sort(vertices.begin(), vertices.end(), FullComparator(desc.stride));
// Count the number of unique vertices
uint32 uniqueVertexCount = 0;
uint32_t uniqueVertexCount = 0;
for (i = 0; i < nVertices; i++)
{
if (i == 0 || !equal(vertices[i - 1], vertices[i], desc.stride))
@ -443,10 +442,10 @@ bool uniquifyVertices(Mesh& mesh)
return true;
// Build the vertex map and the uniquified vertex data
vector<uint32> vertexMap(nVertices);
vector<uint32_t> vertexMap(nVertices);
auto* newVertexData = new char[uniqueVertexCount * desc.stride];
const char* oldVertexData = reinterpret_cast<const char*>(mesh.getVertexData());
uint32 j = 0;
uint32_t j = 0;
for (i = 0; i < nVertices; i++)
{
if (i == 0 || !equal(vertices[i - 1], vertices[i], desc.stride))
@ -473,8 +472,8 @@ bool uniquifyVertices(Mesh& mesh)
Vector3f
getVertex(const void* vertexData,
int positionOffset,
uint32 stride,
uint32 index)
uint32_t stride,
uint32_t index)
{
const float* fdata = reinterpret_cast<const float*>(reinterpret_cast<const char*>(vertexData) + stride * index + positionOffset);
@ -485,8 +484,8 @@ getVertex(const void* vertexData,
Vector2f
getTexCoord(const void* vertexData,
int texCoordOffset,
uint32 stride,
uint32 index)
uint32_t stride,
uint32_t index)
{
const float* fdata = reinterpret_cast<const float*>(reinterpret_cast<const char*>(vertexData) + stride * index + texCoordOffset);
@ -496,17 +495,17 @@ getTexCoord(const void* vertexData,
Vector3f
averageFaceVectors(const vector<Face>& faces,
uint32 thisFace,
uint32* vertexFaces,
uint32 vertexFaceCount,
uint32_t thisFace,
uint32*_t vertexFaces,
uint32_t vertexFaceCount,
float cosSmoothingAngle)
{
const Face& face = faces[thisFace];
Vector3f v = Vector3f(0, 0, 0);
for (uint32 i = 0; i < vertexFaceCount; i++)
for (uint32_t i = 0; i < vertexFaceCount; i++)
{
uint32 f = vertexFaces[i];
uint32_t f = vertexFaces[i];
float cosAngle = face.normal.dot(faces[f].normal);
if (f == thisFace || cosAngle > cosSmoothingAngle)
v += faces[f].normal;
@ -526,14 +525,14 @@ copyVertex(void* newVertexData,
const Mesh::VertexDescription& newDesc,
const void* oldVertexData,
const Mesh::VertexDescription& oldDesc,
uint32 oldIndex,
const uint32 fromOffsets[])
uint32_t oldIndex,
const uint32_t fromOffsets[])
{
const char* oldVertex = reinterpret_cast<const char*>(oldVertexData) +
oldDesc.stride * oldIndex;
auto* newVertex = reinterpret_cast<char*>(newVertexData);
for (uint32 i = 0; i < newDesc.nAttributes; i++)
for (uint32_t i = 0; i < newDesc.nAttributes; i++)
{
if (fromOffsets[i] != ~0)
{
@ -551,11 +550,11 @@ augmentVertexDescription(Mesh::VertexDescription& desc,
Mesh::VertexAttributeFormat format)
{
Mesh::VertexAttribute* attributes = new Mesh::VertexAttribute[desc.nAttributes + 1];
uint32 stride = 0;
uint32 nAttributes = 0;
uint32_t stride = 0;
uint32_t nAttributes = 0;
bool foundMatch = false;
for (uint32 i = 0; i < desc.nAttributes; i++)
for (uint32_t i = 0; i < desc.nAttributes; i++)
{
if (semantic == desc.attributes[i].semantic &&
format != desc.attributes[i].format)
@ -604,19 +603,19 @@ joinVertices(vector<Face>& faces,
// Must have a position
assert(desc.getAttribute(Mesh::Position).format == Mesh::Float3);
uint32 posOffset = desc.getAttribute(Mesh::Position).offset;
uint32_t posOffset = desc.getAttribute(Mesh::Position).offset;
const char* vertexPoints = reinterpret_cast<const char*>(vertexData) +
posOffset;
uint32 nVertices = faces.size() * 3;
uint32_t nVertices = faces.size() * 3;
// Initialize the array of vertices
vector<Vertex> vertices(nVertices);
uint32 f;
uint32_t f;
for (f = 0; f < faces.size(); f++)
{
for (uint32 j = 0; j < 3; j++)
for (uint32_t j = 0; j < 3; j++)
{
uint32 index = faces[f].i[j];
uint32_t index = faces[f].i[j];
vertices[f * 3 + j] = Vertex(index,
vertexPoints + desc.stride * index);
@ -627,10 +626,10 @@ joinVertices(vector<Face>& faces,
sort(vertices.begin(), vertices.end(), orderingPredicate);
// Build the vertex merge map
vector<uint32> mergeMap(nVertices);
uint32 lastUnique = 0;
uint32 uniqueCount = 0;
for (uint32 i = 0; i < nVertices; i++)
vector<uint32_t> mergeMap(nVertices);
uint32_t lastUnique = 0;
uint32_t uniqueCount = 0;
for (uint32_t i = 0; i < nVertices; i++)
{
if (i == 0 || !equivalencePredicate(vertices[i - 1], vertices[i]))
{
@ -644,7 +643,7 @@ joinVertices(vector<Face>& faces,
// Remap the vertex indices
for (f = 0; f < faces.size(); f++)
{
for (uint32 k= 0; k < 3; k++)
for (uint32_t k= 0; k < 3; k++)
faces[f].vi[k] = mergeMap[faces[f].i[k]];
}
}
@ -655,7 +654,7 @@ generateNormals(Mesh& mesh,
float smoothAngle,
bool weld)
{
uint32 nVertices = mesh.getVertexCount();
uint32_t nVertices = mesh.getVertexCount();
auto cosSmoothAngle = (float) cos(smoothAngle);
const Mesh::VertexDescription& desc = mesh.getVertexDescription();
@ -665,10 +664,10 @@ generateNormals(Mesh& mesh,
cerr << "Vertex position must be a float3\n";
return nullptr;
}
uint32 posOffset = desc.getAttribute(Mesh::Position).offset;
uint32_t posOffset = desc.getAttribute(Mesh::Position).offset;
uint32 nFaces = 0;
uint32 i;
uint32_t nFaces = 0;
uint32_t i;
for (i = 0; mesh.getGroup(i) != nullptr; i++)
{
const Mesh::PrimitiveGroup* group = mesh.getGroup(i);
@ -704,7 +703,7 @@ generateNormals(Mesh& mesh,
// and fans into triangle lists.
vector<Face> faces(nFaces);
uint32 f = 0;
uint32_t f = 0;
for (i = 0; mesh.getGroup(i) != nullptr; i++)
{
const Mesh::PrimitiveGroup* group = mesh.getGroup(i);
@ -713,7 +712,7 @@ generateNormals(Mesh& mesh,
{
case Mesh::TriList:
{
for (uint32 j = 0; j < group->nIndices / 3; j++)
for (uint32_t j = 0; j < group->nIndices / 3; j++)
{
assert(f < nFaces);
faces[f].i[0] = group->indices[j * 3];
@ -726,7 +725,7 @@ generateNormals(Mesh& mesh,
case Mesh::TriStrip:
{
for (uint32 j = 2; j < group->nIndices; j++)
for (uint32_t j = 2; j < group->nIndices; j++)
{
assert(f < nFaces);
if (j % 2 == 0)
@ -748,7 +747,7 @@ generateNormals(Mesh& mesh,
case Mesh::TriFan:
{
for (uint32 j = 2; j < group->nIndices; j++)
for (uint32_t j = 2; j < group->nIndices; j++)
{
assert(f < nFaces);
faces[f].i[0] = group->indices[0];
@ -783,8 +782,8 @@ generateNormals(Mesh& mesh,
}
// For each vertex, create a list of faces that contain it
uint32* faceCounts = new uint32[nVertices];
uint32** vertexFaces = new uint32*[nVertices];
uint32*_t faceCounts = new uint32[nVertices];_t
uint32**_t vertexFaces = new uint32*[nVertices];_t
// Initialize the lists
for (i = 0; i < nVertices; i++)
@ -826,7 +825,7 @@ generateNormals(Mesh& mesh,
{
if (faceCounts[i] > 0)
{
vertexFaces[i] = new uint32[faceCounts[i] + 1];
vertexFaces[i] = new uint32[faceCounts[i]_t + 1];
vertexFaces[i][0] = faceCounts[i];
}
}
@ -845,7 +844,7 @@ generateNormals(Mesh& mesh,
for (f = 0; f < nFaces; f++)
{
Face& face = faces[f];
for (uint32 j = 0; j < 3; j++)
for (uint32_t j = 0; j < 3; j++)
{
vertexNormals[f * 3 + j] =
averageFaceVectors(faces, f,
@ -865,8 +864,8 @@ generateNormals(Mesh& mesh,
// mesh. In order to do this, we need the old offset of each attribute
// in the new vertex description. The fromOffsets array will contain
// this mapping.
uint32 normalOffset = 0;
uint32 fromOffsets[16];
uint32_t normalOffset = 0;
uint32_t fromOffsets[16];
for (i = 0; i < newDesc.nAttributes; i++)
{
fromOffsets[i] = ~0;
@ -877,7 +876,7 @@ generateNormals(Mesh& mesh,
}
else
{
for (uint32 j = 0; j < desc.nAttributes; j++)
for (uint32_t j = 0; j < desc.nAttributes; j++)
{
if (desc.attributes[j].semantic == newDesc.attributes[i].semantic)
{
@ -896,7 +895,7 @@ generateNormals(Mesh& mesh,
{
Face& face = faces[f];
for (uint32 j = 0; j < 3; j++)
for (uint32_t j = 0; j < 3; j++)
{
char* newVertex = reinterpret_cast<char*>(newVertexData) +
(f * 3 + j) * newDesc.stride;
@ -915,12 +914,12 @@ generateNormals(Mesh& mesh,
newMesh->setVertices(nFaces * 3, newVertexData);
// Create a trivial index list
uint32* indices = new uint32[nFaces * 3];
uint32*_t indices = new uint32[nFaces_t * 3];
for (i = 0; i < nFaces * 3; i++)
indices[i] = i;
uint32 firstIndex = 0;
for (uint32 groupIndex = 0; mesh.getGroup(groupIndex) != 0; ++groupIndex)
uint32_t firstIndex = 0;
for (uint32_t groupIndex = 0; mesh.getGroup(groupIndex) != 0; ++groupIndex)
{
const Mesh::PrimitiveGroup* group = mesh.getGroup(groupIndex);
unsigned int faceCount = 0;
@ -960,7 +959,7 @@ Mesh*
generateTangents(Mesh& mesh,
bool weld)
{
uint32 nVertices = mesh.getVertexCount();
uint32_t nVertices = mesh.getVertexCount();
// In order to generate tangents, we require positions, normals, and
// 2D texture coordinates in the vertex description.
@ -991,8 +990,8 @@ generateTangents(Mesh& mesh,
// Count the number of faces in the mesh.
// (All geometry should already converted to triangle lists)
uint32 i;
uint32 nFaces = 0;
uint32_t i;
uint32_t nFaces = 0;
for (i = 0; mesh.getGroup(i) != nullptr; i++)
{
const Mesh::PrimitiveGroup* group = mesh.getGroup(i);
@ -1012,7 +1011,7 @@ generateTangents(Mesh& mesh,
// and fans into triangle lists.
vector<Face> faces(nFaces);
uint32 f = 0;
uint32_t f = 0;
for (i = 0; mesh.getGroup(i) != nullptr; i++)
{
const Mesh::PrimitiveGroup* group = mesh.getGroup(i);
@ -1021,7 +1020,7 @@ generateTangents(Mesh& mesh,
{
case Mesh::TriList:
{
for (uint32 j = 0; j < group->nIndices / 3; j++)
for (uint32_t j = 0; j < group->nIndices / 3; j++)
{
assert(f < nFaces);
faces[f].i[0] = group->indices[j * 3];
@ -1034,9 +1033,9 @@ generateTangents(Mesh& mesh,
}
}
uint32 posOffset = desc.getAttribute(Mesh::Position).offset;
uint32 normOffset = desc.getAttribute(Mesh::Normal).offset;
uint32 texCoordOffset = desc.getAttribute(Mesh::Texture0).offset;
uint32_t posOffset = desc.getAttribute(Mesh::Position).offset;
uint32_t normOffset = desc.getAttribute(Mesh::Normal).offset;
uint32_t texCoordOffset = desc.getAttribute(Mesh::Texture0).offset;
const void* vertexData = mesh.getVertexData();
@ -1062,8 +1061,8 @@ generateTangents(Mesh& mesh,
}
// For each vertex, create a list of faces that contain it
uint32* faceCounts = new uint32[nVertices];
uint32** vertexFaces = new uint32*[nVertices];
uint32*_t faceCounts = new uint32[nVertices];_t
uint32**_t vertexFaces = new uint32*[nVertices];_t
// Initialize the lists
for (i = 0; i < nVertices; i++)
@ -1105,7 +1104,7 @@ generateTangents(Mesh& mesh,
{
if (faceCounts[i] > 0)
{
vertexFaces[i] = new uint32[faceCounts[i] + 1];
vertexFaces[i] = new uint32[faceCounts[i]_t + 1];
vertexFaces[i][0] = faceCounts[i];
}
}
@ -1124,7 +1123,7 @@ generateTangents(Mesh& mesh,
for (f = 0; f < nFaces; f++)
{
Face& face = faces[f];
for (uint32 j = 0; j < 3; j++)
for (uint32_t j = 0; j < 3; j++)
{
vertexTangents[f * 3 + j] =
averageFaceVectors(faces, f,
@ -1142,8 +1141,8 @@ generateTangents(Mesh& mesh,
// mesh. In order to do this, we need the old offset of each attribute
// in the new vertex description. The fromOffsets array will contain
// this mapping.
uint32 tangentOffset = 0;
uint32 fromOffsets[16];
uint32_t tangentOffset = 0;
uint32_t fromOffsets[16];
for (i = 0; i < newDesc.nAttributes; i++)
{
fromOffsets[i] = ~0;
@ -1154,7 +1153,7 @@ generateTangents(Mesh& mesh,
}
else
{
for (uint32 j = 0; j < desc.nAttributes; j++)
for (uint32_t j = 0; j < desc.nAttributes; j++)
{
if (desc.attributes[j].semantic == newDesc.attributes[i].semantic)
{
@ -1173,7 +1172,7 @@ generateTangents(Mesh& mesh,
{
Face& face = faces[f];
for (uint32 j = 0; j < 3; j++)
for (uint32_t j = 0; j < 3; j++)
{
char* newVertex = reinterpret_cast<char*>(newVertexData) +
(f * 3 + j) * newDesc.stride;
@ -1192,12 +1191,12 @@ generateTangents(Mesh& mesh,
newMesh->setVertices(nFaces * 3, newVertexData);
// Create a trivial index list
uint32* indices = new uint32[nFaces * 3];
uint32*_t indices = new uint32[nFaces_t * 3];
for (i = 0; i < nFaces * 3; i++)
indices[i] = i;
uint32 firstIndex = 0;
for (uint32 groupIndex = 0; mesh.getGroup(groupIndex) != 0; ++groupIndex)
uint32_t firstIndex = 0;
for (uint32_t groupIndex = 0; mesh.getGroup(groupIndex) != 0; ++groupIndex)
{
const Mesh::PrimitiveGroup* group = mesh.getGroup(groupIndex);
unsigned int faceCount = 0;
@ -1236,13 +1235,13 @@ generateTangents(Mesh& mesh,
void
addGroupWithOffset(Mesh& mesh,
const Mesh::PrimitiveGroup& group,
uint32 offset)
uint32_t offset)
{
if (group.nIndices == 0)
return;
uint32* newIndices = new uint32[group.nIndices];
for (uint32 i = 0; i < group.nIndices; i++)
uint32*_t newIndices = new uint32[group.nIndices];_t
for (uint32_t i = 0; i < group.nIndices; i++)
newIndices[i] = group.indices[i] + offset;
mesh.addGroup(group.prim, group.materialIndex,
@ -1256,7 +1255,7 @@ mergeModelMeshes(const Model& model)
{
vector<Mesh*> meshes;
for (uint32 i = 0; model.getMesh(i) != nullptr; i++)
for (uint32_t i = 0; model.getMesh(i) != nullptr; i++)
{
meshes.push_back(model.getMesh(i));
}
@ -1267,19 +1266,19 @@ mergeModelMeshes(const Model& model)
Model* newModel = new Model();
// Copy materials into the new model
for (uint32 i = 0; model.getMaterial(i) != nullptr; i++)
for (uint32_t i = 0; model.getMaterial(i) != nullptr; i++)
{
newModel->addMaterial(model.getMaterial(i));
}
uint32 meshIndex = 0;
uint32_t meshIndex = 0;
while (meshIndex < meshes.size())
{
const Mesh::VertexDescription& desc =
meshes[meshIndex]->getVertexDescription();
// Count the number of matching meshes
uint32 nMatchingMeshes;
uint32_t nMatchingMeshes;
for (nMatchingMeshes = 1;
meshIndex + nMatchingMeshes < meshes.size();
nMatchingMeshes++)
@ -1291,8 +1290,8 @@ mergeModelMeshes(const Model& model)
}
// Count the number of vertices in all matching meshes
uint32 totalVertices = 0;
uint32 j;
uint32_t totalVertices = 0;
uint32_t j;
for (j = meshIndex; j < meshIndex + nMatchingMeshes; j++)
{
totalVertices += meshes[j]->getVertexCount();
@ -1306,7 +1305,7 @@ mergeModelMeshes(const Model& model)
mergedMesh->setVertices(totalVertices, vertexData);
// Copy the vertex data and reindex and add primitive groups
uint32 vertexCount = 0;
uint32_t vertexCount = 0;
for (j = meshIndex; j < meshIndex + nMatchingMeshes; j++)
{
const Mesh* mesh = meshes[j];
@ -1314,7 +1313,7 @@ mergeModelMeshes(const Model& model)
mesh->getVertexData(),
mesh->getVertexCount() * desc.stride);
for (uint32 k = 0; mesh->getGroup(k) != nullptr; k++)
for (uint32_t k = 0; mesh->getGroup(k) != nullptr; k++)
{
addGroupWithOffset(*mergedMesh, *mesh->getGroup(k),
vertexCount);
@ -1346,7 +1345,7 @@ convertToStrips(Mesh& mesh)
}
// Verify that the mesh contains just tri strips
uint32 i;
uint32_t i;
for (i = 0; mesh.getGroup(i) != nullptr; i++)
{
if (mesh.getGroup(i)->prim != Mesh::TriList)
@ -1360,7 +1359,7 @@ convertToStrips(Mesh& mesh)
// Convert the vertex indices to shorts for the TriStrip library
unsigned short* indices = new unsigned short[group->nIndices];
uint32 j;
uint32_t j;
for (j = 0; j < group->nIndices; j++)
{
indices[j] = (unsigned short) group->indices[j];
@ -1406,8 +1405,8 @@ convertToStrips(Mesh& mesh)
newGroup->prim = prim;
newGroup->materialIndex = group->materialIndex;
newGroup->nIndices = strips[j].numIndices;
newGroup->indices = new uint32[newGroup->nIndices];
for (uint32 k = 0; k < newGroup->nIndices; k++)
newGroup->indices = new uint32[newGroup->nIndices];_t
for (uint32_t k = 0; k < newGroup->nIndices; k++)
newGroup->indices[k] = strips[j].indices[k];
groups.push_back(newGroup);
@ -1548,7 +1547,7 @@ int main(int argc, char* argv[])
if (genNormals || genTangents)
{
Model* newModel = new Model();
uint32 i;
uint32_t i;
// Copy materials
for (i = 0; model->getMaterial(i) != nullptr; i++)
@ -1602,7 +1601,7 @@ int main(int argc, char* argv[])
if (uniquify)
{
for (uint32 i = 0; model->getMesh(i) != nullptr; i++)
for (uint32_t i = 0; model->getMesh(i) != nullptr; i++)
{
Mesh* mesh = model->getMesh(i);
uniquifyVertices(*mesh);
@ -1613,7 +1612,7 @@ int main(int argc, char* argv[])
if (stripify)
{
SetCacheSize(vertexCacheSize);
for (uint32 i = 0; model->getMesh(i) != nullptr; i++)
for (uint32_t i = 0; model->getMesh(i) != nullptr; i++)
{
Mesh* mesh = model->getMesh(i);
convertToStrips(*mesh);

View File

@ -24,7 +24,6 @@ CELUTIL_SOURCES = \
CELUTIL_HEADERS = \
../../../celutil/debug.h \
../../../celutil/basictypes.h \
../../../celutil/bytes.h
CELMATH_HEADERS = \

View File

@ -11,8 +11,6 @@
using namespace std;
using uint32 = unsigned int;
// TODO: these shouldn't be hardcoded
static int latSamples = 1440;
static int longSamples = 2880;
@ -22,18 +20,18 @@ const float pi = 3.14159265;
static float* samples = nullptr;
// Read a big-endian 32-bit unsigned integer
static uint32 readUint(istream& in)
static uint32_t readUint(istream& in)
{
uint32 ret;
in.read((char*) &ret, sizeof(uint32));
return (uint32) ret;
uint32_t ret;
in.read((char*) &ret, sizeof(uint32_t));
return (uint32_t) ret;
}
static float readFloat(istream& in)
{
uint32 i = readUint(in);
uint32 n = ((i & 0xff) << 24) | ((i & 0xff00) << 8) | ((i & 0xff0000) >> 8) | ((i & 0xff000000) >> 24);
uint32_t i = readUint(in);
uint32_t n = ((i & 0xff) << 24) | ((i & 0xff00) << 8) | ((i & 0xff0000) >> 8) | ((i & 0xff000000) >> 24);
return *((float*) &n);
}

View File

@ -116,7 +116,7 @@ private:
};
inline uint qHash(const ShaderKey& key)
inline unsigned int qHash(const ShaderKey& key)
{
return qHash(key.hash());
}

View File

@ -11,7 +11,6 @@
#include "cmodops.h"
#include <celmodel/modelfile.h>
#include <celutil/basictypes.h>
#include <celmath/mathlib.h>
#include <Eigen/Core>
#include <algorithm>
@ -102,8 +101,8 @@ private:
class PointTexCoordOrderingPredicate : public VertexComparator
{
public:
PointTexCoordOrderingPredicate(uint32 _posOffset,
uint32 _texCoordOffset,
PointTexCoordOrderingPredicate(uint32_t _posOffset,
uint32_t _texCoordOffset,
bool _wrap) :
posOffset(_posOffset),
texCoordOffset(_texCoordOffset),
@ -161,8 +160,8 @@ public:
}
private:
uint32 posOffset;
uint32 texCoordOffset;
uint32_t posOffset;
uint32_t texCoordOffset;
bool wrap;
};
@ -176,7 +175,7 @@ bool approxEqual(float x, float y, float prec)
class PointEquivalencePredicate : public VertexComparator
{
public:
PointEquivalencePredicate(uint32 _posOffset,
PointEquivalencePredicate(uint32_t _posOffset,
float _tolerance) :
posOffset(_posOffset),
tolerance(_tolerance)
@ -196,7 +195,7 @@ public:
}
private:
uint32 posOffset;
uint32_t posOffset;
float tolerance;
};
@ -204,8 +203,8 @@ private:
class PointTexCoordEquivalencePredicate : public VertexComparator
{
public:
PointTexCoordEquivalencePredicate(uint32 _posOffset,
uint32 _texCoordOffset,
PointTexCoordEquivalencePredicate(uint32_t _posOffset,
uint32_t _texCoordOffset,
bool _wrap,
float _tolerance) :
posOffset(_posOffset),
@ -232,19 +231,19 @@ public:
}
private:
uint32 posOffset;
uint32 texCoordOffset;
uint32_t posOffset;
uint32_t texCoordOffset;
bool wrap;
float tolerance;
};
bool equal(const Vertex& a, const Vertex& b, uint32 vertexSize)
bool equal(const Vertex& a, const Vertex& b, uint32_t vertexSize)
{
const auto* s0 = reinterpret_cast<const char*>(a.attributes);
const auto* s1 = reinterpret_cast<const char*>(b.attributes);
for (uint32 i = 0; i < vertexSize; i++)
for (uint32_t i = 0; i < vertexSize; i++)
{
if (s0[i] != s1[i])
return false;
@ -301,7 +300,7 @@ bool operator==(const Mesh::VertexDescription& a,
if (a.stride != b.stride || a.nAttributes != b.nAttributes)
return false;
for (uint32 i = 0; i < a.nAttributes; i++)
for (uint32_t i = 0; i < a.nAttributes; i++)
{
if (!(a.attributes[i] == b.attributes[i]))
return false;
@ -324,7 +323,7 @@ bool operator<(const Mesh::VertexDescription& a,
if (b.nAttributes < b.nAttributes)
return false;
for (uint32 i = 0; i < a.nAttributes; i++)
for (uint32_t i = 0; i < a.nAttributes; i++)
{
if (a.attributes[i] < b.attributes[i])
return true;
@ -356,7 +355,7 @@ private:
bool
UniquifyVertices(Mesh& mesh)
{
uint32 nVertices = mesh.getVertexCount();
uint32_t nVertices = mesh.getVertexCount();
const Mesh::VertexDescription& desc = mesh.getVertexDescription();
if (nVertices == 0)
@ -368,7 +367,7 @@ UniquifyVertices(Mesh& mesh)
// Initialize the array of vertices
vector<Vertex> vertices(nVertices);
uint32 i;
uint32_t i;
for (i = 0; i < nVertices; i++)
{
vertices[i] = Vertex(i, vertexData + i * desc.stride);
@ -378,7 +377,7 @@ UniquifyVertices(Mesh& mesh)
sort(vertices.begin(), vertices.end(), FullComparator(desc.stride));
// Count the number of unique vertices
uint32 uniqueVertexCount = 0;
uint32_t uniqueVertexCount = 0;
for (i = 0; i < nVertices; i++)
{
if (i == 0 || !equal(vertices[i - 1], vertices[i], desc.stride))
@ -390,10 +389,10 @@ UniquifyVertices(Mesh& mesh)
return true;
// Build the vertex map and the uniquified vertex data
vector<uint32> vertexMap(nVertices);
vector<uint32_t> vertexMap(nVertices);
auto* newVertexData = new char[uniqueVertexCount * desc.stride];
const char* oldVertexData = reinterpret_cast<const char*>(mesh.getVertexData());
uint32 j = 0;
uint32_t j = 0;
for (i = 0; i < nVertices; i++)
{
if (i == 0 || !equal(vertices[i - 1], vertices[i], desc.stride))
@ -420,8 +419,8 @@ UniquifyVertices(Mesh& mesh)
Vector3f
getVertex(const void* vertexData,
int positionOffset,
uint32 stride,
uint32 index)
uint32_t stride,
uint32_t index)
{
const float* fdata = reinterpret_cast<const float*>(reinterpret_cast<const char*>(vertexData) + stride * index + positionOffset);
@ -432,8 +431,8 @@ getVertex(const void* vertexData,
Vector2f
getTexCoord(const void* vertexData,
int texCoordOffset,
uint32 stride,
uint32 index)
uint32_t stride,
uint32_t index)
{
const float* fdata = reinterpret_cast<const float*>(reinterpret_cast<const char*>(vertexData) + stride * index + texCoordOffset);
@ -443,17 +442,17 @@ getTexCoord(const void* vertexData,
Vector3f
averageFaceVectors(const vector<Face>& faces,
uint32 thisFace,
uint32* vertexFaces,
uint32 vertexFaceCount,
uint32_t thisFace,
uint32*_t vertexFaces,
uint32_t vertexFaceCount,
float cosSmoothingAngle)
{
const Face& face = faces[thisFace];
Vector3f v = Vector3f(0, 0, 0);
for (uint32 i = 0; i < vertexFaceCount; i++)
for (uint32_t i = 0; i < vertexFaceCount; i++)
{
uint32 f = vertexFaces[i];
uint32_t f = vertexFaces[i];
float cosAngle = face.normal.dot(faces[f].normal);
if (f == thisFace || cosAngle > cosSmoothingAngle)
v += faces[f].normal;
@ -473,14 +472,14 @@ copyVertex(void* newVertexData,
const Mesh::VertexDescription& newDesc,
const void* oldVertexData,
const Mesh::VertexDescription& oldDesc,
uint32 oldIndex,
const uint32 fromOffsets[])
uint32_t oldIndex,
const uint32_t fromOffsets[])
{
const char* oldVertex = reinterpret_cast<const char*>(oldVertexData) +
oldDesc.stride * oldIndex;
auto* newVertex = reinterpret_cast<char*>(newVertexData);
for (uint32 i = 0; i < newDesc.nAttributes; i++)
for (uint32_t i = 0; i < newDesc.nAttributes; i++)
{
if (fromOffsets[i] != ~0u)
{
@ -498,11 +497,11 @@ augmentVertexDescription(Mesh::VertexDescription& desc,
Mesh::VertexAttributeFormat format)
{
Mesh::VertexAttribute* attributes = new Mesh::VertexAttribute[desc.nAttributes + 1];
uint32 stride = 0;
uint32 nAttributes = 0;
uint32_t stride = 0;
uint32_t nAttributes = 0;
bool foundMatch = false;
for (uint32 i = 0; i < desc.nAttributes; i++)
for (uint32_t i = 0; i < desc.nAttributes; i++)
{
if (semantic == desc.attributes[i].semantic &&
format != desc.attributes[i].format)
@ -551,7 +550,7 @@ augmentVertexDescription(Mesh::VertexDescription& desc,
cmod::Mesh*
GenerateNormals(const cmod::Mesh& mesh, float smoothAngle, bool weld, float weldTolerance)
{
uint32 nVertices = mesh.getVertexCount();
uint32_t nVertices = mesh.getVertexCount();
float cosSmoothAngle = (float) cos(smoothAngle);
const Mesh::VertexDescription& desc = mesh.getVertexDescription();
@ -561,10 +560,10 @@ GenerateNormals(const cmod::Mesh& mesh, float smoothAngle, bool weld, float weld
cerr << "Vertex position must be a float3\n";
return nullptr;
}
uint32 posOffset = desc.getAttribute(Mesh::Position).offset;
uint32_t posOffset = desc.getAttribute(Mesh::Position).offset;
uint32 nFaces = 0;
uint32 i;
uint32_t nFaces = 0;
uint32_t i;
for (i = 0; mesh.getGroup(i) != nullptr; i++)
{
const Mesh::PrimitiveGroup* group = mesh.getGroup(i);
@ -600,7 +599,7 @@ GenerateNormals(const cmod::Mesh& mesh, float smoothAngle, bool weld, float weld
// and fans into triangle lists.
vector<Face> faces(nFaces);
uint32 f = 0;
uint32_t f = 0;
for (i = 0; mesh.getGroup(i) != nullptr; i++)
{
const Mesh::PrimitiveGroup* group = mesh.getGroup(i);
@ -609,7 +608,7 @@ GenerateNormals(const cmod::Mesh& mesh, float smoothAngle, bool weld, float weld
{
case Mesh::TriList:
{
for (uint32 j = 0; j < group->nIndices / 3; j++)
for (uint32_t j = 0; j < group->nIndices / 3; j++)
{
assert(f < nFaces);
faces[f].i[0] = group->indices[j * 3];
@ -622,7 +621,7 @@ GenerateNormals(const cmod::Mesh& mesh, float smoothAngle, bool weld, float weld
case Mesh::TriStrip:
{
for (uint32 j = 2; j < group->nIndices; j++)
for (uint32_t j = 2; j < group->nIndices; j++)
{
assert(f < nFaces);
if (j % 2 == 0)
@ -644,7 +643,7 @@ GenerateNormals(const cmod::Mesh& mesh, float smoothAngle, bool weld, float weld
case Mesh::TriFan:
{
for (uint32 j = 2; j < group->nIndices; j++)
for (uint32_t j = 2; j < group->nIndices; j++)
{
assert(f < nFaces);
faces[f].i[0] = group->indices[0];
@ -679,8 +678,8 @@ GenerateNormals(const cmod::Mesh& mesh, float smoothAngle, bool weld, float weld
}
// For each vertex, create a list of faces that contain it
uint32* faceCounts = new uint32[nVertices];
uint32** vertexFaces = new uint32*[nVertices];
uint32*_t faceCounts = new uint32[nVertices];_t
uint32**_t vertexFaces = new uint32*[nVertices];_t
// Initialize the lists
for (i = 0; i < nVertices; i++)
@ -722,7 +721,7 @@ GenerateNormals(const cmod::Mesh& mesh, float smoothAngle, bool weld, float weld
{
if (faceCounts[i] > 0)
{
vertexFaces[i] = new uint32[faceCounts[i] + 1];
vertexFaces[i] = new uint32[faceCounts[i]_t + 1];
vertexFaces[i][0] = faceCounts[i];
}
}
@ -741,7 +740,7 @@ GenerateNormals(const cmod::Mesh& mesh, float smoothAngle, bool weld, float weld
for (f = 0; f < nFaces; f++)
{
Face& face = faces[f];
for (uint32 j = 0; j < 3; j++)
for (uint32_t j = 0; j < 3; j++)
{
vertexNormals[f * 3 + j] =
averageFaceVectors(faces, f,
@ -761,8 +760,8 @@ GenerateNormals(const cmod::Mesh& mesh, float smoothAngle, bool weld, float weld
// mesh. In order to do this, we need the old offset of each attribute
// in the new vertex description. The fromOffsets array will contain
// this mapping.
uint32 normalOffset = 0;
uint32 fromOffsets[16];
uint32_t normalOffset = 0;
uint32_t fromOffsets[16];
for (i = 0; i < newDesc.nAttributes; i++)
{
fromOffsets[i] = ~0;
@ -773,7 +772,7 @@ GenerateNormals(const cmod::Mesh& mesh, float smoothAngle, bool weld, float weld
}
else
{
for (uint32 j = 0; j < desc.nAttributes; j++)
for (uint32_t j = 0; j < desc.nAttributes; j++)
{
if (desc.attributes[j].semantic == newDesc.attributes[i].semantic)
{
@ -792,7 +791,7 @@ GenerateNormals(const cmod::Mesh& mesh, float smoothAngle, bool weld, float weld
{
Face& face = faces[f];
for (uint32 j = 0; j < 3; j++)
for (uint32_t j = 0; j < 3; j++)
{
char* newVertex = reinterpret_cast<char*>(newVertexData) +
(f * 3 + j) * newDesc.stride;
@ -811,14 +810,14 @@ GenerateNormals(const cmod::Mesh& mesh, float smoothAngle, bool weld, float weld
newMesh->setVertices(nFaces * 3, newVertexData);
// Create a trivial index list
uint32* indices = new uint32[nFaces * 3];
uint32*_t indices = new uint32[nFaces_t * 3];
for (i = 0; i < nFaces * 3; i++)
{
indices[i] = i;
}
uint32 firstIndex = 0;
for (uint32 groupIndex = 0; mesh.getGroup(groupIndex) != 0; ++groupIndex)
uint32_t firstIndex = 0;
for (uint32_t groupIndex = 0; mesh.getGroup(groupIndex) != 0; ++groupIndex)
{
const Mesh::PrimitiveGroup* group = mesh.getGroup(groupIndex);
unsigned int faceCount = 0;
@ -857,7 +856,7 @@ GenerateNormals(const cmod::Mesh& mesh, float smoothAngle, bool weld, float weld
Mesh*
GenerateTangents(const Mesh& mesh, bool weld)
{
uint32 nVertices = mesh.getVertexCount();
uint32_t nVertices = mesh.getVertexCount();
// In order to generate tangents, we require positions, normals, and
// 2D texture coordinates in the vertex description.
@ -888,8 +887,8 @@ GenerateTangents(const Mesh& mesh, bool weld)
// Count the number of faces in the mesh.
// (All geometry should already converted to triangle lists)
uint32 i;
uint32 nFaces = 0;
uint32_t i;
uint32_t nFaces = 0;
for (i = 0; mesh.getGroup(i) != nullptr; i++)
{
const Mesh::PrimitiveGroup* group = mesh.getGroup(i);
@ -909,7 +908,7 @@ GenerateTangents(const Mesh& mesh, bool weld)
// and fans into triangle lists.
vector<Face> faces(nFaces);
uint32 f = 0;
uint32_t f = 0;
for (i = 0; mesh.getGroup(i) != nullptr; i++)
{
const Mesh::PrimitiveGroup* group = mesh.getGroup(i);
@ -918,7 +917,7 @@ GenerateTangents(const Mesh& mesh, bool weld)
{
case Mesh::TriList:
{
for (uint32 j = 0; j < group->nIndices / 3; j++)
for (uint32_t j = 0; j < group->nIndices / 3; j++)
{
assert(f < nFaces);
faces[f].i[0] = group->indices[j * 3];
@ -934,8 +933,8 @@ GenerateTangents(const Mesh& mesh, bool weld)
}
}
uint32 posOffset = desc.getAttribute(Mesh::Position).offset;
uint32 texCoordOffset = desc.getAttribute(Mesh::Texture0).offset;
uint32_t posOffset = desc.getAttribute(Mesh::Position).offset;
uint32_t texCoordOffset = desc.getAttribute(Mesh::Texture0).offset;
const void* vertexData = mesh.getVertexData();
@ -961,8 +960,8 @@ GenerateTangents(const Mesh& mesh, bool weld)
}
// For each vertex, create a list of faces that contain it
uint32* faceCounts = new uint32[nVertices];
uint32** vertexFaces = new uint32*[nVertices];
uint32*_t faceCounts = new uint32[nVertices];_t
uint32**_t vertexFaces = new uint32*[nVertices];_t
// Initialize the lists
for (i = 0; i < nVertices; i++)
@ -1004,7 +1003,7 @@ GenerateTangents(const Mesh& mesh, bool weld)
{
if (faceCounts[i] > 0)
{
vertexFaces[i] = new uint32[faceCounts[i] + 1];
vertexFaces[i] = new uint32[faceCounts[i]_t + 1];
vertexFaces[i][0] = faceCounts[i];
}
}
@ -1023,7 +1022,7 @@ GenerateTangents(const Mesh& mesh, bool weld)
for (f = 0; f < nFaces; f++)
{
Face& face = faces[f];
for (uint32 j = 0; j < 3; j++)
for (uint32_t j = 0; j < 3; j++)
{
vertexTangents[f * 3 + j] =
averageFaceVectors(faces, f,
@ -1041,8 +1040,8 @@ GenerateTangents(const Mesh& mesh, bool weld)
// mesh. In order to do this, we need the old offset of each attribute
// in the new vertex description. The fromOffsets array will contain
// this mapping.
uint32 tangentOffset = 0;
uint32 fromOffsets[16];
uint32_t tangentOffset = 0;
uint32_t fromOffsets[16];
for (i = 0; i < newDesc.nAttributes; i++)
{
fromOffsets[i] = ~0;
@ -1053,7 +1052,7 @@ GenerateTangents(const Mesh& mesh, bool weld)
}
else
{
for (uint32 j = 0; j < desc.nAttributes; j++)
for (uint32_t j = 0; j < desc.nAttributes; j++)
{
if (desc.attributes[j].semantic == newDesc.attributes[i].semantic)
{
@ -1072,7 +1071,7 @@ GenerateTangents(const Mesh& mesh, bool weld)
{
Face& face = faces[f];
for (uint32 j = 0; j < 3; j++)
for (uint32_t j = 0; j < 3; j++)
{
char* newVertex = reinterpret_cast<char*>(newVertexData) +
(f * 3 + j) * newDesc.stride;
@ -1091,12 +1090,12 @@ GenerateTangents(const Mesh& mesh, bool weld)
newMesh->setVertices(nFaces * 3, newVertexData);
// Create a trivial index list
uint32* indices = new uint32[nFaces * 3];
uint32*_t indices = new uint32[nFaces_t * 3];
for (i = 0; i < nFaces * 3; i++)
indices[i] = i;
uint32 firstIndex = 0;
for (uint32 groupIndex = 0; mesh.getGroup(groupIndex) != 0; ++groupIndex)
uint32_t firstIndex = 0;
for (uint32_t groupIndex = 0; mesh.getGroup(groupIndex) != 0; ++groupIndex)
{
const Mesh::PrimitiveGroup* group = mesh.getGroup(groupIndex);
unsigned int faceCount = 0;
@ -1135,13 +1134,13 @@ GenerateTangents(const Mesh& mesh, bool weld)
void
addGroupWithOffset(Mesh& mesh,
const Mesh::PrimitiveGroup& group,
uint32 offset)
uint32_t offset)
{
if (group.nIndices == 0)
return;
uint32* newIndices = new uint32[group.nIndices];
for (uint32 i = 0; i < group.nIndices; i++)
uint32*_t newIndices = new uint32[group.nIndices];_t
for (uint32_t i = 0; i < group.nIndices; i++)
newIndices[i] = group.indices[i] + offset;
mesh.addGroup(group.prim, group.materialIndex,
@ -1155,7 +1154,7 @@ MergeModelMeshes(const Model& model)
{
vector<Mesh*> meshes;
for (uint32 i = 0; model.getMesh(i) != nullptr; i++)
for (uint32_t i = 0; model.getMesh(i) != nullptr; i++)
{
meshes.push_back(model.getMesh(i));
}
@ -1166,19 +1165,19 @@ MergeModelMeshes(const Model& model)
Model* newModel = new Model();
// Copy materials into the new model
for (uint32 i = 0; model.getMaterial(i) != nullptr; i++)
for (uint32_t i = 0; model.getMaterial(i) != nullptr; i++)
{
newModel->addMaterial(model.getMaterial(i));
}
uint32 meshIndex = 0;
uint32_t meshIndex = 0;
while (meshIndex < meshes.size())
{
const Mesh::VertexDescription& desc =
meshes[meshIndex]->getVertexDescription();
// Count the number of matching meshes
uint32 nMatchingMeshes;
uint32_t nMatchingMeshes;
for (nMatchingMeshes = 1;
meshIndex + nMatchingMeshes < meshes.size();
nMatchingMeshes++)
@ -1190,8 +1189,8 @@ MergeModelMeshes(const Model& model)
}
// Count the number of vertices in all matching meshes
uint32 totalVertices = 0;
uint32 j;
uint32_t totalVertices = 0;
uint32_t j;
for (j = meshIndex; j < meshIndex + nMatchingMeshes; j++)
{
totalVertices += meshes[j]->getVertexCount();
@ -1205,7 +1204,7 @@ MergeModelMeshes(const Model& model)
mergedMesh->setVertices(totalVertices, vertexData);
// Copy the vertex data and reindex and add primitive groups
uint32 vertexCount = 0;
uint32_t vertexCount = 0;
for (j = meshIndex; j < meshIndex + nMatchingMeshes; j++)
{
const Mesh* mesh = meshes[j];
@ -1213,7 +1212,7 @@ MergeModelMeshes(const Model& model)
mesh->getVertexData(),
mesh->getVertexCount() * desc.stride);
for (uint32 k = 0; mesh->getGroup(k) != nullptr; k++)
for (uint32_t k = 0; mesh->getGroup(k) != nullptr; k++)
{
addGroupWithOffset(*mergedMesh, *mesh->getGroup(k),
vertexCount);
@ -1311,7 +1310,7 @@ convertToStrips(Mesh& mesh)
}
// Verify that the mesh contains just tri strips
uint32 i;
uint32_t i;
for (i = 0; mesh.getGroup(i) != nullptr; i++)
{
if (mesh.getGroup(i)->prim != Mesh::TriList)
@ -1325,7 +1324,7 @@ convertToStrips(Mesh& mesh)
// Convert the vertex indices to shorts for the TriStrip library
unsigned short* indices = new unsigned short[group->nIndices];
uint32 j;
uint32_t j;
for (j = 0; j < group->nIndices; j++)
{
indices[j] = (unsigned short) group->indices[j];
@ -1371,8 +1370,8 @@ convertToStrips(Mesh& mesh)
newGroup->prim = prim;
newGroup->materialIndex = group->materialIndex;
newGroup->nIndices = strips[j].numIndices;
newGroup->indices = new uint32[newGroup->nIndices];
for (uint32 k = 0; k < newGroup->nIndices; k++)
newGroup->indices = new uint32[newGroup->nIndices];_t
for (uint32_t k = 0; k < newGroup->nIndices; k++)
newGroup->indices[k] = strips[j].indices[k];
groups.push_back(newGroup);
@ -1399,7 +1398,7 @@ convertToStrips(Mesh& mesh)
if (genNormals || genTangents)
{
Model* newModel = new Model();
uint32 i;
uint32_t i;
// Copy materials
for (i = 0; model->getMaterial(i) != nullptr; i++)
@ -1453,7 +1452,7 @@ convertToStrips(Mesh& mesh)
if (uniquify)
{
for (uint32 i = 0; model->getMesh(i) != nullptr; i++)
for (uint32_t i = 0; model->getMesh(i) != nullptr; i++)
{
Mesh* mesh = model->getMesh(i);
uniquifyVertices(*mesh);
@ -1464,7 +1463,7 @@ convertToStrips(Mesh& mesh)
if (stripify)
{
SetCacheSize(vertexCacheSize);
for (uint32 i = 0; model->getMesh(i) != nullptr; i++)
for (uint32_t i = 0; model->getMesh(i) != nullptr; i++)
{
Mesh* mesh = model->getMesh(i);
convertToStrips(*mesh);

View File

@ -13,7 +13,6 @@
#define _CMODOPS_H_
#include <celmodel/model.h>
#include <celutil/basictypes.h>
#include <Eigen/Core>
#include <vector>
@ -23,10 +22,10 @@ struct Vertex
Vertex() :
index(0), attributes(nullptr) {};
Vertex(uint32 _index, const void* _attributes) :
Vertex(uint32_t _index, const void* _attributes) :
index(_index), attributes(_attributes) {};
uint32 index;
uint32_t index;
const void* attributes;
};
@ -34,8 +33,8 @@ struct Vertex
struct Face
{
Eigen::Vector3f normal;
uint32 i[3]; // vertex attribute indices
uint32 vi[3]; // vertex point indices -- same as above unless welding
uint32_t i[3]; // vertex attribute indices
uint32_t vi[3]; // vertex point indices -- same as above unless welding
};
@ -63,19 +62,19 @@ JoinVertices(std::vector<Face>& faces,
// Must have a position
assert(desc.getAttribute(cmod::Mesh::Position).format == cmod::Mesh::Float3);
uint32 posOffset = desc.getAttribute(cmod::Mesh::Position).offset;
uint32_t posOffset = desc.getAttribute(cmod::Mesh::Position).offset;
const char* vertexPoints = reinterpret_cast<const char*>(vertexData) +
posOffset;
uint32 nVertices = faces.size() * 3;
uint32_t nVertices = faces.size() * 3;
// Initialize the array of vertices
std::vector<Vertex> vertices(nVertices);
uint32 f;
uint32_t f;
for (f = 0; f < faces.size(); f++)
{
for (uint32 j = 0; j < 3; j++)
for (uint32_t j = 0; j < 3; j++)
{
uint32 index = faces[f].i[j];
uint32_t index = faces[f].i[j];
vertices[f * 3 + j] = Vertex(index,
vertexPoints + desc.stride * index);
@ -86,10 +85,10 @@ JoinVertices(std::vector<Face>& faces,
sort(vertices.begin(), vertices.end(), orderingPredicate);
// Build the vertex merge map
std::vector<uint32> mergeMap(nVertices);
uint32 lastUnique = 0;
uint32 uniqueCount = 0;
for (uint32 i = 0; i < nVertices; i++)
std::vector<uint32_t> mergeMap(nVertices);
uint32_t lastUnique = 0;
uint32_t uniqueCount = 0;
for (uint32_t i = 0; i < nVertices; i++)
{
if (i == 0 || !equivalencePredicate(vertices[i - 1], vertices[i]))
{
@ -103,7 +102,7 @@ JoinVertices(std::vector<Face>& faces,
// Remap the vertex indices
for (f = 0; f < faces.size(); f++)
{
for (uint32 k= 0; k < 3; k++)
for (uint32_t k= 0; k < 3; k++)
{
faces[f].vi[k] = mergeMap[faces[f].i[k]];
}

View File

@ -84,8 +84,8 @@ Convert3DSMesh(Model& model,
}
Mesh::VertexAttribute attributes[8];
uint32 nAttributes = 0;
uint32 offset = 0;
uint32_t nAttributes = 0;
uint32_t offset = 0;
// Position attribute is always present
attributes[nAttributes] = Mesh::VertexAttribute(Mesh::Position, Mesh::Float3, 0);
@ -111,11 +111,11 @@ Convert3DSMesh(Model& model,
// No material groups in the 3DS file. This is allowed. We'll create a single
// primitive group with the default material.
unsigned int faceCount = mesh3ds.getFaceCount();
uint32* indices = new uint32[faceCount * 3];
auto* indices = new uint32_t[faceCount * 3];
for (unsigned int i = 0; i < faceCount; i++)
{
uint16 v0 = 0, v1 = 0, v2 = 0;
uint16_t v0 = 0, v1 = 0, v2 = 0;
mesh3ds.getFace(i, v0, v1, v2);
indices[i * 3 + 0] = v0;
indices[i * 3 + 1] = v1;
@ -128,17 +128,17 @@ Convert3DSMesh(Model& model,
{
// We have at least one material group. Create a cmod primitive group for
// each material group in th 3ds mesh.
for (uint32 groupIndex = 0; groupIndex < mesh3ds.getMeshMaterialGroupCount(); ++groupIndex)
for (uint32_t groupIndex = 0; groupIndex < mesh3ds.getMeshMaterialGroupCount(); ++groupIndex)
{
M3DMeshMaterialGroup* matGroup = mesh3ds.getMeshMaterialGroup(groupIndex);
uint32 nMatGroupFaces = matGroup->faces.size();
uint32* indices = new uint32[nMatGroupFaces * 3];
uint32_t nMatGroupFaces = matGroup->faces.size();
auto* indices = new uint32_t[nMatGroupFaces * 3];
for (unsigned int i = 0; i < nMatGroupFaces; i++)
{
uint16 v0 = 0, v1 = 0, v2 = 0;
uint16 faceIndex = matGroup->faces[i];
uint16_t v0 = 0, v1 = 0, v2 = 0;
uint16_t faceIndex = matGroup->faces[i];
mesh3ds.getFace(faceIndex, v0, v1, v2);
indices[i * 3 + 0] = v0;
indices[i * 3 + 1] = v1;

View File

@ -20,7 +20,6 @@
#include <cassert>
#include <stdio.h>
#include <math.h> /* All mathematics */
#include <celutil/basictypes.h>
#include <celutil/bytes.h>
#include <celengine/astro.h>
#include <celengine/stellarclass.h>
@ -86,9 +85,9 @@ void Usage()
cerr << " --index (or -x) : dump new HD or SAO binary x-ref catalogs to text\n\n";
}
static uint32 readUint(istream& in)
static uint32_t readUint(istream& in)
{
uint32 n;
uint32_t n;
in.read(reinterpret_cast<char*>(&n), sizeof n);
LE_TO_CPU_INT32(n, n);
return n;
@ -102,30 +101,30 @@ static float readFloat(istream& in)
return f;
}
static int16 readShort(istream& in)
static int16_t readShort(istream& in)
{
int16 n;
int16_t n;
in.read(reinterpret_cast<char*>(&n), sizeof n);
LE_TO_CPU_INT16(n, n);
return n;
}
static uint16 readUshort(istream& in)
static uint16_t readUshort(istream& in)
{
uint16 n;
uint16_t n;
in.read(reinterpret_cast<char*>(&n), sizeof n);
LE_TO_CPU_INT16(n, n);
return n;
}
static uint8 readUbyte(istream& in)
static uint8_t readUbyte(istream& in)
{
uint8 n;
uint8_t n;
in.read((char*) &n, 1);
return n;
}
void printStellarClass(uint16 sc, ostream& out)
void printStellarClass(uint16_t sc, ostream& out)
{
StellarClass::StarType st = (StellarClass::StarType) (sc >> 12);
if (st == StellarClass::WhiteDwarf)
@ -209,7 +208,7 @@ bool DumpxRefDatabase(istream& in, ostream& out)
}
// Verify the version
uint16 version = readUshort(in);
uint16_t version = readUshort(in);
if (version != 0x0100)
{
cerr << "Bad version for cross index\n";
@ -217,7 +216,7 @@ bool DumpxRefDatabase(istream& in, ostream& out)
}
uint32 record = 0;
uint32_t record = 0;
for (;;)
{
if (!in.good())
@ -226,10 +225,10 @@ bool DumpxRefDatabase(istream& in, ostream& out)
return false;
}
uint32 catalogNum = readUint(in); //HD or SAO number
uint32_t catalogNum = readUint(in); //HD or SAO number
if (in.eof())
break;
uint32 celcatalogNum = readUint(in); //HIP number
uint32_t celcatalogNum = readUint(in); //HIP number
out << catalogNum << ' ';
out << celcatalogNum << '\n';
@ -312,7 +311,7 @@ C
bool DumpStarDatabase(istream& in, ostream& out)
{
uint32 hi; // HI catalog number
uint32_t hi; // HI catalog number
double rafrh;
double rafrm;
double rah; // right ascension hh
@ -324,7 +323,7 @@ bool DumpStarDatabase(istream& in, ostream& out)
double ded; // declination degrees
double dem; // declination minutes
double des; // declination seconds
uint16 sc; // stellar class
uint16_t sc; // stellar class
double ly; // light years
char buf[256]; // character buffer
@ -337,7 +336,7 @@ bool DumpStarDatabase(istream& in, ostream& out)
return false;
}
uint16 version = readUshort(in);
uint16_t version = readUshort(in);
if (version != 0x0100)
{
cerr << "Unsupported file version " << (version >> 8) << '.' <<
@ -345,7 +344,7 @@ bool DumpStarDatabase(istream& in, ostream& out)
return false;
}
uint32 nStarsInFile = readUint(in);
uint32_t nStarsInFile = readUint(in);
if (!in.good())
{
cerr << "Error reading count of stars from database.\n";
@ -357,7 +356,7 @@ bool DumpStarDatabase(istream& in, ostream& out)
printf("\n\nStart converting %d", nStarsInFile);
printf(" records.\n");
for (uint32 i = 0; i < nStarsInFile; i++)
for (uint32_t i = 0; i < nStarsInFile; i++)
{
if (!in.good())
{
@ -367,12 +366,12 @@ bool DumpStarDatabase(istream& in, ostream& out)
if (i % 5000 == 0)
printf(".");
uint32 catalogNum = readUint(in);
float x = readFloat(in);
float y = readFloat(in);
float z = readFloat(in);
int16 absMag = readShort(in);
uint16 stellarClass = readUshort(in);
uint32_t catalogNum = readUint(in);
float x = readFloat(in);
float y = readFloat(in);
float z = readFloat(in);
int16_t absMag = readShort(in);
uint16_t stellarClass = readUshort(in);
double pi = 3.14159265358979323846;
//distance = sqrt(x^2 + y^2 + z^2) in ly
@ -461,7 +460,7 @@ bool DumpStarDatabase(istream& in, ostream& out)
bool Convert2csv(istream& in, ostream& out,bool all)
{
uint32 hi; // HI catalog number
uint32_t hi; // HI catalog number
double rafrh;
double rafrm;
double rah; // right ascension hh
@ -473,7 +472,7 @@ bool Convert2csv(istream& in, ostream& out,bool all)
double ded; // declination degrees
double dem; // declination minutes
double des; // declination seconds
uint16 sc; // stellar class
uint16_t sc; // stellar class
double ly; // light years
char buf[256]; // character buffer
@ -486,7 +485,7 @@ bool Convert2csv(istream& in, ostream& out,bool all)
return false;
}
uint16 version = readUshort(in);
uint16_t version = readUshort(in);
if (version != 0x0100)
{
cerr << "Unsupported file version " << (version >> 8) << '.' <<
@ -494,7 +493,7 @@ bool Convert2csv(istream& in, ostream& out,bool all)
return false;
}
uint32 nStarsInFile = readUint(in);
uint32_t nStarsInFile = readUint(in);
if (!in.good())
{
cerr << "Error reading count of stars from database.\n";
@ -542,7 +541,7 @@ bool Convert2csv(istream& in, ostream& out,bool all)
out << HEADER_NEW;
//HEADER_NEW = "HIP number;RAdeg;DECdeg;RA(hms);DEC(dms);Distance(LY);Parallax;AppMag;AbsMag;StellarClass\n"
for (uint32 i = 0; i < nStarsInFile; i++)
for (uint32_t i = 0; i < nStarsInFile; i++)
{
if (!in.good())
{
@ -552,12 +551,12 @@ bool Convert2csv(istream& in, ostream& out,bool all)
if (i % 5000 == 0)
printf(".");
uint32 catalogNum = readUint(in);
float x = readFloat(in);
float y = readFloat(in);
float z = readFloat(in);
int16 absMag = readShort(in);
uint16 stellarClass = readUshort(in);
uint32_t catalogNum = readUint(in);
float x = readFloat(in);
float y = readFloat(in);
float z = readFloat(in);
int16_t absMag = readShort(in);
uint16_t stellarClass = readUshort(in);
double pi = 3.14159265358979323846;
double distance = sqrt(pow(x,2)+pow(y,2)+pow(z,2));
@ -659,7 +658,7 @@ bool Convert2csv(istream& in, ostream& out,bool all)
bool Const2csv(istream& in, ostream& out)
{
uint32 hi; // HI catalog number
uint32_t hi; // HI catalog number
double rafrh;
double rafrm;
double rah; // right ascension hh
@ -671,7 +670,7 @@ bool Const2csv(istream& in, ostream& out)
double ded; // declination degrees
double dem; // declination minutes
double des; // declination seconds
uint16 sc; // stellar class
uint16_t sc; // stellar class
double ly; // light years
char buf[256]; // character buffer
@ -683,7 +682,7 @@ bool Const2csv(istream& in, ostream& out)
return false;
}
uint16 version = readUshort(in);
uint16_t version = readUshort(in);
if (version != 0x0100)
{
cerr << "Unsupported file version " << (version >> 8) << '.' <<
@ -691,7 +690,7 @@ bool Const2csv(istream& in, ostream& out)
return false;
}
uint32 nStarsInFile = readUint(in);
uint32_t nStarsInFile = readUint(in);
if (!in.good())
{
cerr << "Error reading count of stars from database.\n";
@ -735,7 +734,7 @@ bool Const2csv(istream& in, ostream& out)
out << buf;
// calculate data for each star
for (uint32 i = 0; i < nStarsInFile; i++)
for (uint32_t i = 0; i < nStarsInFile; i++)
{
if (!in.good())
{
@ -745,12 +744,12 @@ bool Const2csv(istream& in, ostream& out)
if (i % 5000 == 0)
printf(".");
// read stardb.dat
uint32 catalogNum = readUint(in);
float x = readFloat(in);
float y = readFloat(in);
float z = readFloat(in);
int16 absMag = readShort(in);
uint16 stellarClass = readUshort(in);
uint32_t catalogNum = readUint(in);
float x = readFloat(in);
float y = readFloat(in);
float z = readFloat(in);
int16_t absMag = readShort(in);
uint16_t stellarClass = readUshort(in);
double pi = 3.14159265358979323846;
double distance = sqrt(pow(x,2)+pow(y,2)+pow(z,2));

View File

@ -14,7 +14,6 @@
#include <iomanip>
#include <cctype>
#include <cassert>
#include <celutil/basictypes.h>
#include <celutil/bytes.h>
#include <celengine/astro.h>
#include <celengine/star.h>
@ -82,7 +81,7 @@ bool parseCommandLine(int argc, char* argv[])
}
static void writeUint(ostream& out, uint32 n)
static void writeUint(ostream& out, uint32_t n)
{
LE_TO_CPU_INT32(n, n);
out.write(reinterpret_cast<char*>(&n), sizeof n);
@ -94,13 +93,13 @@ static void writeFloat(ostream& out, float f)
out.write(reinterpret_cast<char*>(&f), sizeof f);
}
static void writeUshort(ostream& out, uint16 n)
static void writeUshort(ostream& out, uint16_t n)
{
LE_TO_CPU_INT16(n, n);
out.write(reinterpret_cast<char*>(&n), sizeof n);
}
static void writeShort(ostream& out, int16 n)
static void writeShort(ostream& out, int16_t n)
{
LE_TO_CPU_INT16(n, n);
out.write(reinterpret_cast<char*>(&n), sizeof n);
@ -207,7 +206,7 @@ bool WriteStarDatabase(istream& in, ostream& out, bool sphericalCoords)
writeFloat(out, x);
writeFloat(out, y);
writeFloat(out, z);
writeShort(out, (int16) (absMag * 256.0f));
writeShort(out, (int16_t) (absMag * 256.0f));
writeUshort(out, sc.pack());
}

View File

@ -13,7 +13,6 @@
#include <fstream>
#include <iomanip>
#include <string>
#include <celutil/basictypes.h>
#include <celutil/bytes.h>
using namespace std;
@ -68,14 +67,14 @@ bool parseCommandLine(int argc, char* argv[])
}
static void writeUint(ostream& out, uint32 n)
static void writeUint(ostream& out, uint32_t n)
{
LE_TO_CPU_INT32(n, n);
out.write(reinterpret_cast<char*>(&n), sizeof n);
}
static void writeShort(ostream& out, int16 n)
static void writeShort(ostream& out, int16_t n)
{
LE_TO_CPU_INT16(n, n);
out.write(reinterpret_cast<char*>(&n), sizeof n);
@ -107,8 +106,8 @@ bool WriteCrossIndex(istream& in, ostream& out)
return false;
}
writeUint(out, (uint32) catalogNumber);
writeUint(out, (uint32) celCatalogNumber);
writeUint(out, (uint32_t) catalogNumber);
writeUint(out, (uint32_t) celCatalogNumber);
record++;
}

View File

@ -13,7 +13,6 @@
#include <iostream>
#include <fstream>
#include <iomanip>
#include <celutil/basictypes.h>
#include <celutil/bytes.h>
#include <celengine/astro.h>
#include <celengine/stellarclass.h>
@ -38,9 +37,9 @@ void Usage()
}
static uint32 readUint(istream& in)
static uint32_t readUint(istream& in)
{
uint32 n;
uint32_t n;
in.read(reinterpret_cast<char*>(&n), sizeof n);
LE_TO_CPU_INT32(n, n);
return n;
@ -54,31 +53,31 @@ static float readFloat(istream& in)
return f;
}
static int16 readShort(istream& in)
static int16_t readShort(istream& in)
{
int16 n;
int16_t n;
in.read(reinterpret_cast<char*>(&n), sizeof n);
LE_TO_CPU_INT16(n, n);
return n;
}
static uint16 readUshort(istream& in)
static uint16_t readUshort(istream& in)
{
uint16 n;
uint16_t n;
in.read(reinterpret_cast<char*>(&n), sizeof n);
LE_TO_CPU_INT16(n, n);
return n;
}
static uint8 readUbyte(istream& in)
static uint8_t readUbyte(istream& in)
{
uint8 n;
uint8_t n;
in.read((char*) &n, 1);
return n;
}
void printStellarClass(uint16 sc, ostream& out)
void printStellarClass(uint16_t sc, ostream& out)
{
StellarClass::StarType st = (StellarClass::StarType) (sc >> 12);
@ -147,7 +146,7 @@ void printStellarClass(uint16 sc, ostream& out)
bool DumpOldStarDatabase(istream& in, ostream& out, ostream* hdOut,
bool spherical)
{
uint32 nStarsInFile = readUint(in);
uint32_t nStarsInFile = readUint(in);
if (!in.good())
{
cerr << "Error reading count of stars from database.\n";
@ -156,7 +155,7 @@ bool DumpOldStarDatabase(istream& in, ostream& out, ostream* hdOut,
out << nStarsInFile << '\n';
for (uint32 i = 0; i < nStarsInFile; i++)
for (uint32_t i = 0; i < nStarsInFile; i++)
{
if (!in.good())
{
@ -164,14 +163,14 @@ bool DumpOldStarDatabase(istream& in, ostream& out, ostream* hdOut,
return false;
}
uint32 catalogNum = readUint(in);
uint32 HDCatalogNum = readUint(in);
uint32_t catalogNum = readUint(in);
uint32_t HDCatalogNum = readUint(in);
float RA = readFloat(in);
float dec = readFloat(in);
float parallax = readFloat(in);
int16 appMag = readShort(in);
uint16 stellarClass = readUshort(in);
uint8 parallaxError = readUbyte(in);
int16_t appMag = readShort(in);
uint16_t stellarClass = readUshort(in);
uint8_t parallaxError = readUbyte(in);
// Compute distance based on parallax
double distance = LY_PER_PARSEC / (parallax > 0.0 ? parallax / 1000.0 : 1e-6);
@ -217,7 +216,7 @@ bool DumpStarDatabase(istream& in, ostream& out, ostream* hdOut)
return false;
}
uint16 version = readUshort(in);
uint16_t version = readUshort(in);
if (version != 0x0100)
{
cerr << "Unsupported file version " << (version >> 8) << '.' <<
@ -225,7 +224,7 @@ bool DumpStarDatabase(istream& in, ostream& out, ostream* hdOut)
return false;
}
uint32 nStarsInFile = readUint(in);
uint32_t nStarsInFile = readUint(in);
if (!in.good())
{
cerr << "Error reading count of stars from database.\n";
@ -234,7 +233,7 @@ bool DumpStarDatabase(istream& in, ostream& out, ostream* hdOut)
out << nStarsInFile << '\n';
for (uint32 i = 0; i < nStarsInFile; i++)
for (uint32_t i = 0; i < nStarsInFile; i++)
{
if (!in.good())
{
@ -242,12 +241,12 @@ bool DumpStarDatabase(istream& in, ostream& out, ostream* hdOut)
return false;
}
uint32 catalogNum = readUint(in);
float x = readFloat(in);
float y = readFloat(in);
float z = readFloat(in);
int16 absMag = readShort(in);
uint16 stellarClass = readUshort(in);
uint32_t catalogNum = readUint(in);
float x = readFloat(in);
float y = readFloat(in);
float z = readFloat(in);
int16_t absMag = readShort(in);
uint16_t stellarClass = readUshort(in);
out << catalogNum << ' ';
out << setprecision(7);