From b8485e4ed18fed6b5e4e49e1b1c20c375bf59a82 Mon Sep 17 00:00:00 2001 From: Steve Hollasch Date: Sat, 2 Nov 2024 19:31:59 -0700 Subject: [PATCH] ray4: deprecate old typedefs --- ray4/src/r4_main.cpp | 48 +++++++++++++++++++++---------------------- ray4/src/r4_parse.cpp | 17 ++++++++------- ray4/src/r4_trace.cpp | 2 +- ray4/src/ray4.h | 23 ++++++++------------- 4 files changed, 41 insertions(+), 49 deletions(-) diff --git a/ray4/src/r4_main.cpp b/ray4/src/r4_main.cpp index f5c0ede..b51679a 100644 --- a/ray4/src/r4_main.cpp +++ b/ray4/src/r4_main.cpp @@ -113,8 +113,8 @@ ImageHeader iheader = { // Output Image Header Vector4 Gx, Gy, Gz; // Ray-Grid Basis Vectors Point4 Gorigin; // Ray-Grid Origin Point int res[3] = {0,0,0}; // Full Output Image Resolution -ulong scanlsize; // Scanline Size -ulong slbuff_count; // Number of Lines in Scanline Buffer +long scanlsize; // Scanline Size +long slbuff_count; // Number of Lines in Scanline Buffer char *scanbuff; // Scanline Buffer time_t StartTime; // Timestamp @@ -221,7 +221,7 @@ char *GetField (char *str, int &value) { if ((*str < '0') || ('9' < *str)) return nullptr; - value = static_cast(atoi(str)); + value = atoi(str); while (('0' <= *str) && (*str <= '9')) ++str; @@ -253,7 +253,7 @@ char *GetRange ( if ((*str < '0') || ('9' < *str)) return nullptr; - val1 = val2 = static_cast(atoi (str)); + val1 = val2 = atoi(str); while (('0' <= *str) && (*str <= '9')) ++str; @@ -271,7 +271,7 @@ char *GetRange ( if ((*str < '0') || ('9' < *str)) return nullptr; - val2 = static_cast(atoi (str)); + val2 = atoi(str); while (('0' <= *str) && (*str <= '9')) ++str; @@ -504,20 +504,20 @@ void ProcessArgs (int argc, char *argv[]) { // Integer Write Routines -- These routines write out values in big-endian format. //================================================================================================== -void WriteInteger8(uchar value) { +void WriteUInteger8(uint8_t value) { WriteBlock(&value, 1); } -void WriteInteger16(ushort value) { - unsigned char block[2]; +void WriteUInteger16(uint16_t value) { + uint8_t block[2]; block[0] = 0xff & (value >> 8); block[1] = 0xff & value; WriteBlock(block, 2); } -void WriteInteger32(ulong value) { - unsigned char block[4]; +void WriteUInteger32(uint32_t value) { + uint8_t block[4]; block[0] = 0xff & (value >> 24); block[1] = 0xff & (value >> 16); block[2] = 0xff & (value >> 8); @@ -529,18 +529,18 @@ void WriteInteger32(ulong value) { //__________________________________________________________________________________________________ void WriteHeader(const ImageHeader& header) { - WriteInteger32(header.magic); - WriteInteger8(header.version); - WriteInteger8(header.bitsperpixel); + WriteUInteger32(header.magic); + WriteUInteger8(header.version); + WriteUInteger8(header.bitsperpixel); for (int i=0; i < 3; ++i) - WriteInteger16(header.aspect[i]); + WriteUInteger16(header.aspect[i]); for (int i=0; i < 3; ++i) - WriteInteger16(header.start[i]); + WriteUInteger16(header.start[i]); for (int i=0; i < 3; ++i) - WriteInteger16(header.end[i]); + WriteUInteger16(header.end[i]); } //__________________________________________________________________________________________________ @@ -604,7 +604,7 @@ void CalcRayGrid (void) { void FireRays () { // This is the main routine that fires the rays through the ray grid and into the 4D scene. - ulong scancount = 0; // Scanline Counter + long scancount = 0; // Scanline Counter char *scanptr = scanbuff; // Scanline Buffer Pointer bool eflag = true; // Even RGB Boundary Flag @@ -647,20 +647,20 @@ void FireRays () { if (iheader.bitsperpixel == 24) { - *scanptr++ = static_cast(color.r); - *scanptr++ = static_cast(color.g); - *scanptr++ = static_cast(color.b); + *scanptr++ = static_cast(color.r); + *scanptr++ = static_cast(color.g); + *scanptr++ = static_cast(color.b); } else if (eflag) { - *scanptr++ = (static_cast(color.r) & 0xF0) | (static_cast(color.g) >> 4); - *scanptr = (static_cast(color.b) & 0xF0); + *scanptr++ = (static_cast(color.r) & 0xF0) | (static_cast(color.g) >> 4); + *scanptr = (static_cast(color.b) & 0xF0); eflag = false; } else { - *scanptr++ |= (static_cast(color.r) >> 4); - *scanptr++ = (static_cast(color.g) & 0xF0) | (static_cast(color.b) >> 4); + *scanptr++ |= (static_cast(color.r) >> 4); + *scanptr++ = (static_cast(color.g) & 0xF0) | (static_cast(color.b) >> 4); eflag = true; } } diff --git a/ray4/src/r4_parse.cpp b/ray4/src/r4_parse.cpp index 977e01b..002fccc 100644 --- a/ray4/src/r4_parse.cpp +++ b/ray4/src/r4_parse.cpp @@ -166,7 +166,7 @@ Triangle DefTriangle = { static AttrName *attrnamelist = nullptr; // Attribute Name List static bool eofflag = false; // Non-Zero If EOF Input File -static ulong lcount = 1; // Input Line Counter +static long lcount = 1; // Input Line Counter static Attributes *prevattr= &DefAttributes; // Previously Named Attribute static char token[MAXTLEN+1]; // Input Token @@ -183,7 +183,7 @@ void Error (const char *format, ...) { va_start(args, format); - printf("Input Error [Line %lu]: ", lcount); + printf("Input Error [Line %l]: ", lcount); vprintf(format, args); print("\n"); @@ -221,7 +221,7 @@ char *GetToken ( } char *ptr = buff; // Destination Buffer Pointer - ushort nn = 0; // Length of Destination String + int nn = 0; // Length of Destination String // Skip past comments and whitespace. @@ -411,7 +411,7 @@ void ReadReal (char *ctoken, double *num) { //__________________________________________________________________________________________________ -void ReadUint16 (char *itoken, ushort *num) { +void ReadUint16 (char *itoken, uint16_t *num) { // This procedure reads in a 16-bit unsigned integer from the input stream and stores it in the // location given in the parameter list. @@ -420,7 +420,7 @@ void ReadUint16 (char *itoken, ushort *num) { GetToken (inbuff, false); if (CType(*inbuff) != NUM) Error ("Missing integer argument for '%s'.", itoken); - *num = static_cast(atoi (inbuff)); + *num = static_cast(atoi(inbuff)); } //__________________________________________________________________________________________________ @@ -487,7 +487,7 @@ void ParseInput () { break; case VarType::UInt16: - ReadUint16 (token, reinterpret_cast(Globals[i].address)); + ReadUint16 (token, reinterpret_cast(Globals[i].address)); break; case VarType::Real: @@ -553,7 +553,7 @@ Attributes *ReadAttributes () { if (newattr->indexref <= 0.0) Error ("Non-positive index of refraction."); } else if (keyeq (token, "refle")) { - ushort scratch; + uint16_t scratch; ReadUint16 (token, &scratch); if (scratch == 1) newattr->flags |= AT_REFLECT; @@ -623,8 +623,7 @@ void DoAttributes () { AttrName *newattrname; // New Attributes Alias Node if (anptr) { - printf ("Warning: Attributes \"%s\" redefined at line %lu.\n", - token, lcount); + printf ("Warning: Attributes \"%s\" redefined at line %l.\n", token, lcount); newattrname = anptr; } else { newattrname = NEW (AttrName, 1); diff --git a/ray4/src/r4_trace.cpp b/ray4/src/r4_trace.cpp index cde3dd5..09b4c48 100644 --- a/ray4/src/r4_trace.cpp +++ b/ray4/src/r4_trace.cpp @@ -37,7 +37,7 @@ Color black { 0, 0, 0 }; // Used to zero out colors. void RayTrace ( const Ray4 &rayIn, // Trace Ray Color &color, // Resulting Color - ulong level) // Raytrace Level + int level) // Raytrace Level { // This routine is the heart of the raytracer; it takes the ray, determines which objects are // hit, picks the closest one, determines the appropriate shade at the surface, and then may or diff --git a/ray4/src/ray4.h b/ray4/src/ray4.h index a90ebb7..931e645 100644 --- a/ray4/src/ray4.h +++ b/ray4/src/ray4.h @@ -41,13 +41,6 @@ -// Basic Type Definitions - -using uchar = unsigned char; -using ulong = unsigned long; -using ushort = unsigned short; - - // Constant Definitions const double epsilon = 1.0e-15; // Very Small Number (Effectively Zero) @@ -99,10 +92,10 @@ inline double lerp (double a, double b, double t) { // Structure Definitions struct Stats { - ulong Ncast; // Number of Rays Cast - ulong Nreflect; // Number of Reflection Rays Cast - ulong Nrefract; // Number of Refraction Rays Cast - ulong maxlevel; // Maximum Ray Tree Level + long Ncast; // Number of Rays Cast + long Nreflect; // Number of Reflection Rays Cast + long Nrefract; // Number of Refraction Rays Cast + long maxlevel; // Maximum Ray Tree Level }; enum class LightType { Point, Directional }; @@ -168,7 +161,7 @@ struct TetPar { // Tetrahedron/Parallelepiped Common Fields Point4 vert[4]; // Vertices Vector4 vec1,vec2,vec3; // Vectors from Vertex 0 to Vertices 1,2,3 Vector4 normal; // Hyperplane Normal Vector - uchar ax1, ax2, ax3; // Non-Dominant Normal Vector Axes + uint8_t ax1, ax2, ax3; // Non-Dominant Normal Vector Axes double planeConst; // Hyperplane Constant double CramerDiv; // Cramer's-Rule Divisor for Barycentric Coords }; @@ -205,7 +198,7 @@ void MyFree (void*); void OpenInput (void); void OpenOutput (void); void ParseInput (void); -void RayTrace (const Ray4&, Color&, ulong); +void RayTrace (const Ray4&, Color&, int); int ReadChar (void); void UnreadChar (int); void WriteBlock (void *block, int size); @@ -220,7 +213,7 @@ void WriteBlock (void *block, int size); double global_indexref = 1.00; // Global Index Refraction char *infile = nullptr; // Input File Name Light *lightlist = nullptr; // Light-Source List - ushort maxdepth = 0; // Maximum Recursion Depth + int maxdepth = 0; // Maximum Recursion Depth ObjInfo *objlist = nullptr; // Object List char *outfile = nullptr; // Output File Name Stats stats = { 0, 0, 0, 0 }; // Status Information @@ -236,7 +229,7 @@ void WriteBlock (void *block, int size); extern double global_indexref; extern char *infile; extern Light *lightlist; - extern ushort maxdepth; + extern int maxdepth; extern ObjInfo *objlist; extern char *outfile; extern Stats stats;