Skip to content

Commit d202f5e

Browse files
committed
Fix zixel and other points
1 parent b53377a commit d202f5e

File tree

2 files changed

+16
-77
lines changed

2 files changed

+16
-77
lines changed

FitdLib/renderer.cpp

Lines changed: 11 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -780,13 +780,13 @@ void processPrim_Poly(int primType, sPrimitive* ptr, char** out)
780780
}
781781
}
782782

783-
void processPrim_Point(int primType, sPrimitive* ptr, char** out)
783+
void processPrim_Point(primTypeEnum primType, sPrimitive* ptr, char** out)
784784
{
785785
primEntryStruct* pCurrentPrimEntry = &primTable[positionInPrimEntry];
786786

787787
ASSERT(positionInPrimEntry < NUM_MAX_PRIM_ENTRY);
788788

789-
pCurrentPrimEntry->type = primTypeEnum_Point;
789+
pCurrentPrimEntry->type = primType;
790790
pCurrentPrimEntry->numOfVertices = 1;
791791
pCurrentPrimEntry->color = ptr->m_color;
792792
pCurrentPrimEntry->material = ptr->m_material;
@@ -849,53 +849,6 @@ void processPrim_Sphere(int primType, sPrimitive* ptr, char** out)
849849
}
850850
}
851851

852-
void processPrim_Point(int primType, char** ptr, char** out) // point
853-
{
854-
u8 pointColor;
855-
u16 pointIndex;
856-
float depth = 32000.f;
857-
primEntryStruct* pCurrentPrimEntry = &primTable[positionInPrimEntry];
858-
859-
(*ptr)++;
860-
pointColor = **ptr;
861-
(*ptr)++;
862-
(*ptr)++;
863-
864-
switch(primType)
865-
{
866-
case primTypeEnum_Point:
867-
pCurrentPrimEntry->type = primTypeEnum_Point;
868-
break;
869-
case primTypeEnum_BigPoint:
870-
pCurrentPrimEntry->type = primTypeEnum_BigPoint;
871-
break;
872-
case primTypeEnum_Zixel:
873-
pCurrentPrimEntry->type = primTypeEnum_Zixel;
874-
break;
875-
default:
876-
assert(0);
877-
break;
878-
}
879-
pCurrentPrimEntry->type = primTypeEnum_Point;
880-
pCurrentPrimEntry->color = pointColor;
881-
882-
pointIndex = *(u16*)(*ptr);
883-
(*ptr)+=2;
884-
885-
ASSERT((pointIndex%2) == 0);
886-
887-
pCurrentPrimEntry->vertices[0].X = renderPointList[pointIndex/2];
888-
pCurrentPrimEntry->vertices[0].Y = renderPointList[(pointIndex/2)+1];
889-
depth = pCurrentPrimEntry->vertices[0].Z = renderPointList[(pointIndex/2)+2];
890-
891-
if(depth > 0)
892-
{
893-
positionInPrimEntry++;
894-
numOfPrimitiveToRender++;
895-
ASSERT(positionInPrimEntry < NUM_MAX_PRIM_ENTRY);
896-
}
897-
}
898-
899852
void primType5(int primType, char** ptr, char** out) // draw out of hardClip
900853
{
901854
printf("ignoring prim type 5\n");
@@ -961,29 +914,22 @@ void renderPoly(primEntryStruct* pEntry) // poly
961914

962915
void renderZixel(primEntryStruct* pEntry) // point
963916
{
964-
float transformedSize;
965-
966-
transformedSize = ((5.f * (float)cameraFovX) / (float)(pEntry->vertices[0].Z+cameraPerspective));
917+
float pointSize = 20.f;
918+
float transformedSize = ((pointSize * (float)cameraFovX) / (float)(pEntry->vertices[0].Z+cameraPerspective));
967919

968920
osystem_drawPoint(pEntry->vertices[0].X,pEntry->vertices[0].Y,pEntry->vertices[0].Z,pEntry->color,transformedSize);
969921
}
970922

971923
void renderPoint(primEntryStruct* pEntry) // point
972924
{
973-
float transformedSize;
974-
975-
transformedSize = ((1.f * (float)cameraFovX) / (float)(pEntry->vertices[0].Z+cameraPerspective));
976-
977-
osystem_drawPoint(pEntry->vertices[0].X,pEntry->vertices[0].Y,pEntry->vertices[0].Z,pEntry->color, transformedSize);
925+
float pointSize = 0.3f; // TODO: better way to compute that?
926+
osystem_drawPoint(pEntry->vertices[0].X,pEntry->vertices[0].Y,pEntry->vertices[0].Z,pEntry->color, pointSize);
978927
}
979928

980929
void renderBigPoint(primEntryStruct* pEntry) // point
981930
{
982-
float transformedSize;
983-
984-
transformedSize = ((2.f * (float)cameraFovX) / (float)(pEntry->vertices[0].Z+cameraPerspective));
985-
986-
osystem_drawPoint(pEntry->vertices[0].X,pEntry->vertices[0].Y,pEntry->vertices[0].Z,pEntry->color, transformedSize);
931+
float bigPointSize = 2.f; // TODO: better way to compute that?
932+
osystem_drawPoint(pEntry->vertices[0].X,pEntry->vertices[0].Y,pEntry->vertices[0].Z,pEntry->color, bigPointSize);
987933
}
988934

989935
void renderSphere(primEntryStruct* pEntry) // sphere
@@ -1008,6 +954,8 @@ renderFunction renderFunctions[]={
1008954
renderPoly, // poly
1009955
renderPoint, // point
1010956
renderSphere, // sphere
957+
nullptr,
958+
nullptr,
1011959
renderBigPoint,
1012960
renderZixel,
1013961
};
@@ -1093,7 +1041,7 @@ int AffObjet(int x,int y,int z,int alpha,int beta,int gamma,void* modelPtr)
10931041
for(i=0;i<numPrim;i++)
10941042
{
10951043
sPrimitive* pPrimitive = &pBody->m_primitives[i];
1096-
u8 primType = pPrimitive->m_type;
1044+
primTypeEnum primType = pPrimitive->m_type;
10971045

10981046
switch(primType)
10991047
{

FitdLib/rendererBGFX.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,23 @@ struct sphereVertex
7878
float U;
7979
float V;
8080

81-
unsigned char R;
82-
unsigned char G;
83-
unsigned char B;
84-
unsigned char A;
85-
8681
float centerX;
8782
float centerY;
8883
float size;
84+
float material;
8985
};
9086

9187
#define NUM_MAX_FLAT_VERTICES 5000*3
9288
#define NUM_MAX_NOISE_VERTICES 2000*3
9389
#define NUM_MAX_TRANSPARENT_VERTICES 1000*2
9490
#define NUM_MAX_RAMP_VERTICES 3000*3
95-
#define NUM_MAX_SPHERES 1000
91+
#define NUM_MAX_SPHERES_VERTICES 3000
9692

9793
std::array<polyVertex, NUM_MAX_FLAT_VERTICES> flatVertices;
9894
std::array<polyVertex, NUM_MAX_NOISE_VERTICES> noiseVertices;
9995
std::array<polyVertex, NUM_MAX_TRANSPARENT_VERTICES> transparentVertices;
10096
std::array<polyVertex, NUM_MAX_RAMP_VERTICES> rampVertices;
101-
std::array<sphereVertex, NUM_MAX_SPHERES> sphereVertices;
97+
std::array<sphereVertex, NUM_MAX_SPHERES_VERTICES> sphereVertices;
10298

10399
int numUsedFlatVertices = 0;
104100
int numUsedNoiseVertices = 0;
@@ -743,8 +739,7 @@ void osystem_flushPendingPrimitives()
743739
.begin()
744740
.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
745741
.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
746-
.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8)
747-
.add(bgfx::Attrib::TexCoord1, 3, bgfx::AttribType::Float)
742+
.add(bgfx::Attrib::TexCoord1, 4, bgfx::AttribType::Float)
748743
.end();
749744

750745
bgfx::TransientVertexBuffer transientBuffer;
@@ -1188,17 +1183,13 @@ void osystem_drawPoint(float X, float Y, float Z, u8 color, float size)
11881183
{
11891184
sphereVertex* pVertex = &sphereVertices[numUsedSpheres];
11901185
numUsedSpheres++;
1191-
assert(numUsedSpheres < NUM_MAX_SPHERES);
1186+
assert(numUsedSpheres < NUM_MAX_SPHERES_VERTICES);
11921187

11931188
pVertex->X = corners[mapping[i]].X;
11941189
pVertex->Y = corners[mapping[i]].Y;
11951190
pVertex->Z = corners[mapping[i]].Z;
11961191
pVertex->U = (color & 0xF) / 15.f;
11971192
pVertex->V = ((color & 0xF0) >> 4) / 15.f;
1198-
pVertex->R = RGB_Pal[color * 3];
1199-
pVertex->G = RGB_Pal[color * 3 + 1];
1200-
pVertex->B = RGB_Pal[color * 3 + 2];
1201-
pVertex->A = 128;
12021193
pVertex->size = size;
12031194
pVertex->centerX = X;
12041195
pVertex->centerY = Y;

0 commit comments

Comments
 (0)