C client: and simplify axislinesrenderer too

This commit is contained in:
UnknownShadow200 2018-09-06 06:32:31 +10:00
parent 2520e649c0
commit d7b61c7e9e
6 changed files with 26 additions and 56 deletions

View file

@ -41,28 +41,30 @@ void AxisLinesRenderer_Render(Real64 delta) {
Gfx_SetTexturing(false);
Vector3 P = LocalPlayer_Instance.Base.Position; P.Y += 0.05f;
VertexP3fC4b vertices[axisLines_numVertices];
Vector3 coords[5]; coords[2] = P;
Vector3_Add1(&coords[0], &P, -axisLines_length);
Vector3_Add1(&coords[1], &P, -axisLines_size);
Vector3_Add1(&coords[3], &P, axisLines_size);
Vector3_Add1(&coords[4], &P, axisLines_length);
static UInt8 faces[36] = {
2,2,1, 2,2,3, 4,2,3, 4,2,1, /* X arrow */
1,2,2, 1,2,4, 3,2,4, 3,2,2, /* Z arrow */
1,2,3, 1,4,3, 3,4,1, 3,2,1, /* Y arrow */
};
static PackedCol cols[3] = { PACKEDCOL_RED, PACKEDCOL_BLUE, PACKEDCOL_GREEN };
Int32 i, count = Camera_Active->IsThirdPerson ? 12 : 8;
VertexP3fC4b* ptr = vertices;
PackedCol red = PACKEDCOL_RED;
SelectionBox_HorQuad(&ptr, red,
P.X, P.Z - axisLines_size,
P.X + axisLines_length, P.Z + axisLines_size,
P.Y);
PackedCol blue = PACKEDCOL_BLUE;
SelectionBox_HorQuad(&ptr, blue,
P.X - axisLines_size, P.Z,
P.X + axisLines_size, P.Z + axisLines_length,
P.Y);
if (Camera_Active->IsThirdPerson) {
PackedCol green = PACKEDCOL_GREEN;
SelectionBox_VerQuad(&ptr, green,
P.X - axisLines_size, P.Y, P.Z + axisLines_size,
P.X + axisLines_size, P.Y + axisLines_length, P.Z - axisLines_size);
for (i = 0; i < count; i++, ptr++) {
ptr->X = coords[faces[i*3 + 0]].X;
ptr->Y = coords[faces[i*3 + 1]].Y;
ptr->Z = coords[faces[i*3 + 2]].Z;
ptr->Col = cols[i];
}
Gfx_SetBatchFormat(VERTEX_FORMAT_P3FC4B);
Int32 count = (Int32)(ptr - vertices);
GfxCommon_UpdateDynamicVb_IndexedTris(axisLines_vb, vertices, count);
}

View file

@ -68,7 +68,7 @@ void PackedCol_ToHex(STRING_TRANSIENT String* str, PackedCol value) {
}
bool PackedCol_TryParseHex(STRING_PURE String* str, PackedCol* value) {
PackedCol empty = PACKEDCOL_CONST(0, 0, 0, 0); *value = empty;
PackedCol empty = { 0 }; *value = empty;
/* accept XXYYZZ or #XXYYZZ forms */
if (str->length < 6) return false;
if (str->length > 6 && (str->buffer[0] != '#' || str->length > 7)) return false;

View file

@ -16,9 +16,9 @@ typedef union PackedCol_ {
} PackedCol;
#if CC_BUILD_D3D9
#define PACKEDCOL_CONST(r, g, b, a) { b, g, r, a };
#define PACKEDCOL_CONST(r, g, b, a) { b, g, r, a }
#else
#define PACKEDCOL_CONST(r, g, b, a) { r, g, b, a };
#define PACKEDCOL_CONST(r, g, b, a) { r, g, b, a }
#endif
PackedCol PackedCol_Create4(UInt8 r, UInt8 g, UInt8 b, UInt8 a);

View file

@ -64,7 +64,7 @@ int main(void) {
String title = String_FromConst(PROGRAM_APP_NAME);
String rawArgs = Platform_GetCommandLineArgs();
/* NOTE: Make sure to comment this out before pushing a commit */
rawArgs = String_FromReadonly("UnknownShadow200 fff 127.0.0.1 25565");
//rawArgs = String_FromReadonly("UnknownShadow200 fff 127.0.0.1 25565");
String args[5]; Int32 argsCount = Array_Elems(args);
String_UNSAFE_Split(&rawArgs, ' ', args, &argsCount);

View file

@ -13,11 +13,11 @@ struct SelectionBox {
Real32 MinDist, MaxDist;
};
void SelectionBox_Render(struct SelectionBox* box, VertexP3fC4b** vertices, VertexP3fC4b** lineVertices) {
static void SelectionBox_Render(struct SelectionBox* box, VertexP3fC4b** vertices, VertexP3fC4b** lineVertices) {
Real32 offset = box->MinDist < 32.0f * 32.0f ? (1.0f / 32.0f) : (1.0f / 16.0f);
Vector3 coords[2];
Vector3_Add1(&coords[0], &box->Min, -offset);
Vector3_Add1(&coords[1], &box->Max, offset);
Vector3_Add1(&coords[1], &box->Max, offset);
Int32 i;
VertexP3fC4b* ptr;
@ -59,31 +59,6 @@ void SelectionBox_Render(struct SelectionBox* box, VertexP3fC4b** vertices, Vert
*lineVertices = ptr;
}
void SelectionBox_VerQuad(VertexP3fC4b** vertices, PackedCol col,
Real32 x1, Real32 y1, Real32 z1, Real32 x2, Real32 y2, Real32 z2) {
VertexP3fC4b* ptr = *vertices;
VertexP3fC4b v; v.Col = col;
v.X = x1; v.Y = y1; v.Z = z1; *ptr++ = v;
v.Y = y2; *ptr++ = v;
v.X = x2; v.Z = z2; *ptr++ = v;
v.Y = y1; *ptr++ = v;
*vertices = ptr;
}
void SelectionBox_HorQuad(VertexP3fC4b** vertices, PackedCol col,
Real32 x1, Real32 z1, Real32 x2, Real32 z2, Real32 y) {
VertexP3fC4b* ptr = *vertices;
VertexP3fC4b v; v.Y = y; v.Col = col;
v.X = x1; v.Z = z1; *ptr++ = v;
v.Z = z2; *ptr++ = v;
v.X = x2; *ptr++ = v;
v.Z = z1; *ptr++ = v;
*vertices = ptr;
}
static Int32 SelectionBox_Compare(struct SelectionBox* a, struct SelectionBox* b) {
Real32 aDist, bDist;
if (a->MinDist == b->MinDist) {

View file

@ -7,13 +7,6 @@
*/
struct IGameComponent;
void SelectionBox_VerQuad(VertexP3fC4b** vertices, PackedCol col,
Real32 x1, Real32 y1, Real32 z1, Real32 x2, Real32 y2, Real32 z2);
void SelectionBox_HorQuad(VertexP3fC4b** vertices, PackedCol col,
Real32 x1, Real32 z1, Real32 x2, Real32 z2, Real32 y);
void SelectionBox_Line(VertexP3fC4b** vertices, PackedCol col,
Real32 x1, Real32 y1, Real32 z1, Real32 x2, Real32 y2, Real32 z2);
void Selections_MakeComponent(struct IGameComponent* comp);
void Selections_Render(Real64 delta);
void Selections_Add(UInt8 id, Vector3I p1, Vector3I p2, PackedCol col);