Replace // with /* comments

This commit is contained in:
UnknownShadow200 2017-06-07 17:36:36 +10:00
parent 59f3c0bc5c
commit e7ff52ff7b
13 changed files with 58 additions and 54 deletions

View File

@ -212,7 +212,7 @@ void BordersRenderer_RebuildEdges(Int32 y, Int32 axisSize) {
for (i = 0; i < 4; i++) {
Rectangle r = borders_rects[i];
borders_edgesVertices += Math_CountVertices(r.Width, r.Height, axisSize); // YPlanes outside
borders_edgesVertices += Math_CountVertices(r.Width, r.Height, axisSize); /* YPlanes outside */
}
VertexP3fT2fC4b v[4096];

View File

@ -5,10 +5,14 @@
#include "Funcs.h"
#include "Lighting.h"
Builder_Offsets = { -1, 1, -EXTCHUNK_SIZE, EXTCHUNK_SIZE, EXTCHUNK_SIZE_2, EXTCHUNK_SIZE_2 };
void Builder_Init(void) {
Builder_WhiteCol = PackedCol_White;
Builder_Offsets[Face_XMin] = -1;
Builder_Offsets[Face_XMax] = 1;
Builder_Offsets[Face_ZMin] = -EXTCHUNK_SIZE;
Builder_Offsets[Face_ZMax] = EXTCHUNK_SIZE;
Builder_Offsets[Face_YMin] = -EXTCHUNK_SIZE_2;
Builder_Offsets[Face_YMax] = EXTCHUNK_SIZE_2;
}
void Builder_SetDefault(void) {

View File

@ -50,7 +50,7 @@ void ChunkSorter_QuickSort(Int32 left, Int32 right) {
while (left < right) {
Int32 i = left, j = right;
UInt32 pivot = keys[(i + j) / 2];
// partition the list
/* partition the list */
while (i <= j) {
while (pivot > keys[i]) i++;
while (pivot < keys[j]) j--;
@ -62,7 +62,7 @@ void ChunkSorter_QuickSort(Int32 left, Int32 right) {
}
}
// recurse into the smaller subset
/* recurse into the smaller subset */
if (j - left <= right - i) {
if (left < j) QuickSort(left, j);
left = i;

View File

@ -37,7 +37,7 @@ BlockID EnvRenderer_BlockOn(Real32* fogDensity, PackedCol* fogCol) {
*fogCol = Block_FogColour[block];
} else {
*fogDensity = 0.0f;
// Blend fog and sky together
/* Blend fog and sky together */
Real32 blend = EnvRenderer_BlendFactor(Game_ViewDistance);
*fogCol = PackedCol_Lerp(WorldEnv_FogCol, WorldEnv_SkyCol, blend);
}
@ -61,7 +61,7 @@ void EnvRenderer_RenderClouds(Real64 delta) {
Real32 offset = (Real32)(time / 2048.0f * 0.6f * WorldEnv_CloudsSpeed);
Gfx_SetMatrixMode(MatrixType_Texture);
Matrix matrix = Matrix_Identity; matrix.Row3.X = offset; // translate X axis
Matrix matrix = Matrix_Identity; matrix.Row3.X = offset; /* translate X axis */
Gfx_LoadMatrix(&matrix);
Gfx_SetMatrixMode(MatrixType_Modelview);

View File

@ -23,7 +23,7 @@ bool FrustumCulling_SphereInFrustum(Real32 x, Real32 y, Real32 z, Real32 radius)
d = frustum40 * x + frustum41 * y + frustum42 * z + frustum43;
if (d <= -radius) return false;
// Don't test NEAR plane, it's pointless
/* Don't test NEAR plane, it's pointless */
return true;
}
@ -32,35 +32,35 @@ void FrustumCulling_CalcFrustumEquations(Matrix* projection, Matrix* modelView)
Matrix_Mul(&clipMatrix, modelView, projection);
Real32* clip = (Real32*)&clipMatrix;
// Extract the numbers for the RIGHT plane
/* Extract the numbers for the RIGHT plane */
frustum00 = clip[3] - clip[0];
frustum01 = clip[7] - clip[4];
frustum02 = clip[11] - clip[8];
frustum03 = clip[15] - clip[12];
FrustumCulling_Normalise(&frustum00, &frustum01, &frustum02, &frustum03);
// Extract the numbers for the LEFT plane
/* Extract the numbers for the LEFT plane */
frustum10 = clip[3] + clip[0];
frustum11 = clip[7] + clip[4];
frustum12 = clip[11] + clip[8];
frustum13 = clip[15] + clip[12];
FrustumCulling_Normalise(&frustum10, &frustum11, &frustum12, &frustum13);
// Extract the BOTTOM plane
/* Extract the BOTTOM plane */
frustum20 = clip[3] + clip[1];
frustum21 = clip[7] + clip[5];
frustum22 = clip[11] + clip[9];
frustum23 = clip[15] + clip[13];
FrustumCulling_Normalise(&frustum20, &frustum21, &frustum22, &frustum23);
// Extract the TOP plane
/* Extract the TOP plane */
frustum30 = clip[3] - clip[1];
frustum31 = clip[7] - clip[5];
frustum32 = clip[11] - clip[9];
frustum33 = clip[15] - clip[13];
FrustumCulling_Normalise(&frustum30, &frustum31, &frustum32, &frustum33);
// Extract the FAR plane
/* Extract the FAR plane */
frustum40 = clip[3] - clip[2];
frustum41 = clip[7] - clip[6];
frustum42 = clip[11] - clip[10];

View File

@ -77,8 +77,8 @@ void GfxCommon_Draw2DTexture(Texture* tex, PackedCol col) {
void GfxCommon_Make2DQuad(Texture* tex, PackedCol col, VertexP3fT2fC4b** vertices) {
Real32 x1 = tex->X, y1 = tex->Y, x2 = tex->X + tex->Width, y2 = tex->Y + tex->Height;
#if USE_DX
/* NOTE: see "https://msdn.microsoft.com/en-us/library/windows/desktop/bb219690(v=vs.85).aspx",
// i.e. the msdn article called "Directly Mapping Texels to Pixels (Direct3D 9)" for why we have to do this. */
/* NOTE: see "https://msdn.microsoft.com/en-us/library/windows/desktop/bb219690(v=vs.85).aspx", */
/* i.e. the msdn article called "Directly Mapping Texels to Pixels (Direct3D 9)" for why we have to do this. */
x1 -= 0.5f; x2 -= 0.5f;
y1 -= 0.5f; y2 -= 0.5f;
#endif

View File

@ -156,10 +156,10 @@ void Lighting_UpdateLighting(Int32 x, Int32 y, Int32 z, BlockID oldBlock, BlockI
Int32 oldOffset = (Block_LightOffset[oldBlock] >> Face_YMax) & 1;
Int32 newOffset = (Block_LightOffset[newBlock] >> Face_YMax) & 1;
// Two cases we need to handle here:
/* Two cases we need to handle here: */
if (didBlock == nowBlocks) {
if (!didBlock) return; // a) both old and new block do not block light
if (oldOffset == newOffset) return; // b) both blocks blocked light at the same Y coordinate
if (!didBlock) return; /* a) both old and new block do not block light */
if (oldOffset == newOffset) return; /* b) both blocks blocked light at the same Y coordinate */
}
if ((y - newOffset) >= lightH) {
@ -291,7 +291,7 @@ Int32 Lighting_InitialHeightmapCoverage(Int32 x1, Int32 z1, Int32 xCount, Int32
}
index++;
}
curRunCount = 0; // We can only skip an entire X row at most.
curRunCount = 0; /* We can only skip an entire X row at most. */
}
return elemsLeft;
}
@ -320,8 +320,8 @@ bool Lighting_CalculateHeightmapCoverage(Int32 x1, Int32 z1, Int32 xCount, Int32
Int32 offset = prevRunCount + curRunCount;
Int32 newRunCount = skip[index - offset] + 1;
// consider case 1 0 1 0, where we are at 0
// we need to make this 3 0 0 0 and advance by 1
/* consider case 1 0 1 0, where we are at 0 */
/* we need to make this 3 0 0 0 and advance by 1 */
Int32 oldRunCount = (x - offset + newRunCount) < xCount ? skip[index - offset + newRunCount] : 0;
if (oldRunCount != 0) {
skip[index - offset + newRunCount] = 0;
@ -337,7 +337,7 @@ bool Lighting_CalculateHeightmapCoverage(Int32 x1, Int32 z1, Int32 xCount, Int32
}
prevRunCount = 0;
heightmapIndex += World_Width;
mapIndex = baseIndex + World_Width; // advance one Z
mapIndex = baseIndex + World_Width; /* advance one Z */
}
}
return false;

View File

@ -58,7 +58,7 @@ void MapRenderer_RenderNormal(Real64 deltaTime) {
void MapRenderer_RenderTranslucent(Real64 deltaTime) {
if (MapRenderer_Chunks == NULL) return;
// First fill depth buffer
/* First fill depth buffer */
UInt32 vertices = Game_Vertices;
Gfx_SetBatchFormat(VertexFormat_P3fT2fC4b);
Gfx_SetTexturing(false);
@ -75,11 +75,11 @@ void MapRenderer_RenderTranslucent(Real64 deltaTime) {
}
Game_Vertices = vertices;
// Then actually draw the transluscent blocks
/* Then actually draw the transluscent blocks */
Gfx_SetAlphaBlending(true);
Gfx_SetTexturing(true);
Gfx_SetColourWrite(true);
Gfx_SetDepthWrite(false); // we already calculated depth values in depth pass
Gfx_SetDepthWrite(false); /* we already calculated depth values in depth pass */
for (batch = 0; batch < MapRenderer_1DUsedCount; batch++) {
if (MapRenderer_PartsCount[batch] <= 0) continue;
@ -89,7 +89,7 @@ void MapRenderer_RenderTranslucent(Real64 deltaTime) {
}
Gfx_SetDepthWrite(true);
// If we weren't under water, render weather after to blend properly
/* If we weren't under water, render weather after to blend properly */
if (!inTranslucent && WorldEnv_Weather != Weather_Sunny) {
Gfx_SetAlphaTest(true);
WeatherRenderer_Render(deltaTime);
@ -108,7 +108,7 @@ void MapRenderer_CheckWeather(Real64 deltaTime) {
bool outside = !World_IsValidPos_3I(coords);
inTranslucent = Block_Draw[block] == DrawType_Translucent || (pos.Y < WorldEnv_EdgeHeight && outside);
// If we are under water, render weather before to blend properly
/* If we are under water, render weather before to blend properly */
if (!inTranslucent || WorldEnv_Weather == Weather_Sunny) return;
Gfx_SetAlphaBlending(true);
WeatherRenderer_Render(deltaTime);
@ -162,7 +162,7 @@ void MapRenderer_RenderNormalBatch(Int32 batch) {
}
offset += part.FrontCount + part.BackCount;
// Special handling for top and bottom face, as these can go over 65536 vertices and we need to adjust the indices in this case.
/* Special handling for top and bottom face, as these can go over 65536 vertices and we need to adjust the indices in this case. */
if (drawYMin && drawYMax) {
Gfx_SetFaceCulling(true);
if (part.IndicesCount > Gfx_MaxIndices) {
@ -196,7 +196,7 @@ void MapRenderer_RenderNormalBatch(Int32 batch) {
}
if (part.SpriteCount == 0) continue;
Int32 count = part.SpriteCount / 4; // 4 per sprite
Int32 count = part.SpriteCount / 4; /* 4 per sprite */
Gfx_SetFaceCulling(true);
if (info->DrawXMax || info->DrawZMin) {
Gfx_DrawIndexedVb_TrisT2fC4b(count, 0); Game_Vertices += count;

View File

@ -11,7 +11,7 @@ Int32 Random_Range(Random* seed, Int32 min, Int32 max) {
}
Int32 Random_Next(Random* seed, Int32 n) {
if ((n & -n) == n) { // i.e., n is a power of 2
if ((n & -n) == n) { /* i.e., n is a power of 2 */
*seed = (*seed * value + 0xBLL) & mask;
Int64 raw = (Int64)((UInt64)*seed >> (48 - 31));
return (Int32)((n * raw) >> 31);

View File

@ -103,42 +103,42 @@ void SkyboxRenderer_MakeVb(void) {
TextureRec rec;
PackedCol col = WorldEnv_CloudsCol;
// Render the front quad
/* Render the front quad */
rec = TextureRec_FromRegion(0.25f, 0.5f, 0.25f, 0.5f);
VertexP3fT2fC4b_Set(&vertices[ 0], extent, -extent, -extent, rec.U1, rec.V2, col);
VertexP3fT2fC4b_Set(&vertices[ 1], -extent, -extent, -extent, rec.U2, rec.V2, col);
VertexP3fT2fC4b_Set(&vertices[ 2], -extent, extent, -extent, rec.U2, rec.V1, col);
VertexP3fT2fC4b_Set(&vertices[ 3], extent, extent, -extent, rec.U1, rec.V1, col);
// Render the left quad
/* Render the left quad */
rec = TextureRec_FromRegion(0.00f, 0.5f, 0.25f, 0.5f);
VertexP3fT2fC4b_Set(&vertices[ 4], extent, -extent, extent, rec.U1, rec.V2, col);
VertexP3fT2fC4b_Set(&vertices[ 5], extent, -extent, -extent, rec.U2, rec.V2, col);
VertexP3fT2fC4b_Set(&vertices[ 6], extent, extent, -extent, rec.U2, rec.V1, col);
VertexP3fT2fC4b_Set(&vertices[ 7], extent, extent, extent, rec.U1, rec.V1, col);
// Render the back quad
/* Render the back quad */
rec = TextureRec_FromRegion(0.75f, 0.5f, 0.25f, 0.5f);
VertexP3fT2fC4b_Set(&vertices[ 8], -extent, -extent, extent, rec.U1, rec.V2, col);
VertexP3fT2fC4b_Set(&vertices[ 9], extent, -extent, extent, rec.U2, rec.V2, col);
VertexP3fT2fC4b_Set(&vertices[10], extent, extent, extent, rec.U2, rec.V1, col);
VertexP3fT2fC4b_Set(&vertices[11], -extent, extent, extent, rec.U1, rec.V1, col);
// Render the right quad
/* Render the right quad */
rec = TextureRec_FromRegion(0.50f, 0.5f, 0.25f, 0.5f);
VertexP3fT2fC4b_Set(&vertices[12], -extent, -extent, -extent, rec.U1, rec.V2, col);
VertexP3fT2fC4b_Set(&vertices[13], -extent, -extent, extent, rec.U2, rec.V2, col);
VertexP3fT2fC4b_Set(&vertices[14], -extent, extent, extent, rec.U2, rec.V1, col);
VertexP3fT2fC4b_Set(&vertices[15], -extent, extent, -extent, rec.U1, rec.V1, col);
// Render the top quad
/* Render the top quad */
rec = TextureRec_FromRegion(0.25f, 0.0f, 0.25f, 0.5f);
VertexP3fT2fC4b_Set(&vertices[16], -extent, extent, -extent, rec.U2, rec.V2, col);
VertexP3fT2fC4b_Set(&vertices[17], -extent, extent, extent, rec.U2, rec.V1, col);
VertexP3fT2fC4b_Set(&vertices[18], extent, extent, extent, rec.U1, rec.V1, col);
VertexP3fT2fC4b_Set(&vertices[19], extent, extent, -extent, rec.U1, rec.V2, col);
// Render the bottom quad
/* Render the bottom quad */
rec = TextureRec_FromRegion(0.50f, 0.0f, 0.25f, 0.5f);
VertexP3fT2fC4b_Set(&vertices[20], -extent, -extent, -extent, rec.U2, rec.V2, col);
VertexP3fT2fC4b_Set(&vertices[21], -extent, -extent, extent, rec.U2, rec.V1, col);

View File

@ -13,7 +13,7 @@ String String_FromRawBuffer(UInt8* buffer, UInt16 capacity) {
String str = String_FromEmptyBuffer(buffer, capacity);
Int32 i;
// Need to set region occupied by string to NUL for interop with native APIs
/* Need to set region occupied by string to NUL for interop with native APIs */
for (i = 0; i < capacity + 1; i++) {
buffer[i] = 0;
}

View File

@ -13,7 +13,7 @@ Int32 Atlas2D_LoadTextureElement(TextureLoc texLoc) {
Int32 size = Atlas2D_ElementSize;
Bitmap element;
// Try to allocate bitmap on stack if possible
/* Try to allocate bitmap on stack if possible */
if (size > 64) {
Bitmap_Allocate(&element, size, size);
if (element.Scan0 == NULL) {

View File

@ -85,7 +85,7 @@ void WeatherRenderer_Render(Real64 deltaTime) {
ParticleManager_AddRainParticle(x, y, z);
Real32 alpha = WeatherRenderer_AlphaAt(dx * dx + dz * dz);
// Clamp between 0 and 255
/* Clamp between 0 and 255 */
alpha = alpha < 0.0f ? 0.0f : alpha;
alpha = alpha > 255.0f ? 255.0f : alpha;
col.A = (UInt8)alpha;
@ -97,22 +97,22 @@ void WeatherRenderer_Render(Real64 deltaTime) {
#define AddVertex *ptr = v; ptr++;
v.X = x; v.Y = y; v.Z = z; v.U = 0; v.V = v1; AddVertex
// (x, y, z) (0, v1)
/* (x, y, z) (0, v1) */
v.Y = y + height; v.V = v2; AddVertex
// (x, y + height, z) (0, v2)
/* (x, y + height, z) (0, v2) */
v.X = x + 1; v.Z = z + 1; v.U = 1; AddVertex
// (x + 1, y + height, z + 1) (1, v2)
/* (x + 1, y + height, z + 1) (1, v2) */
v.Y = y; v.V = v1; AddVertex
// (x + 1, y, z + 1) (1, v1)
/* (x + 1, y, z + 1) (1, v1) */
v.Z = z; AddVertex
// (x + 1, y, z) (1, v1)
/* (x + 1, y, z) (1, v1) */
v.Y = y + height; v.V = v2; AddVertex
// (x + 1, y + height, z) (1, v2)
/* (x + 1, y + height, z) (1, v2) */
v.X = x; v.Z = z + 1; v.U = 0; AddVertex
// (x, y + height, z + 1) (0, v2)
/* (x, y + height, z + 1) (0, v2) */
v.Y = y; v.V = v1; AddVertex
// (x y, z + 1) (0, v1)
/* (x y, z + 1) (0, v1) */
}
if (particles && (weather_accumulator >= 0.25 || moved))
@ -132,7 +132,7 @@ void WeatherRenderer_Render(Real64 deltaTime) {
}
Real32 WeatherRenderer_AlphaAt(Real32 x) {
// Wolfram Alpha: fit {0,178},{1,169},{4,147},{9,114},{16,59},{25,9}
/* Wolfram Alpha: fit {0,178},{1,169},{4,147},{9,114},{16,59},{25,9} */
Real32 falloff = 0.05f * x * x - 7 * x;
return 178 + falloff * WorldEnv_WeatherFade;
}
@ -210,17 +210,17 @@ void WeatherRenderer_OnBlockChanged(Int32 x, Int32 y, Int32 z, BlockID oldBlock,
Int32 index = (x * World_Length) + z;
Int32 height = weather_heightmap[index];
// Two cases can be skipped here:
// a) rain height was not calculated to begin with (height is short.MaxValue)
// b) changed y is below current calculated rain height
/* Two cases can be skipped here: */
/* a) rain height was not calculated to begin with (height is short.MaxValue) */
/* b) changed y is below current calculated rain height */
if (y < height) return;
if (nowBlock) {
// Simple case: Rest of column below is now not visible to rain.
/* Simple case: Rest of column below is now not visible to rain. */
weather_heightmap[index] = (Int16)y;
} else {
// Part of the column is now visible to rain, we don't know how exactly how high it should be though.
// However, we know that if the old block was above or equal to rain height, then the new rain height must be <= old block.y
/* Part of the column is now visible to rain, we don't know how exactly how high it should be though. */
/* However, we know that if the old block was above or equal to rain height, then the new rain height must be <= old block.y */
WeatherRenderer_CalcHeightAt(x, y, z, index);
}
}