mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -04:00
Slightly optimise held block outline rendering
This commit is contained in:
parent
695d066233
commit
0e5a7ea17f
@ -526,8 +526,7 @@ static void Game_Render3D(double delta, float t) {
|
|||||||
|
|
||||||
Entities_DrawShadows();
|
Entities_DrawShadows();
|
||||||
if (Game_SelectedPos.Valid && !Game_HideGui) {
|
if (Game_SelectedPos.Valid && !Game_HideGui) {
|
||||||
PickedPosRenderer_Update(&Game_SelectedPos);
|
PickedPosRenderer_Render(&Game_SelectedPos, true);
|
||||||
PickedPosRenderer_Render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Render water over translucent blocks when under the water outside the map for proper alpha blending */
|
/* Render water over translucent blocks when under the water outside the map for proper alpha blending */
|
||||||
@ -543,7 +542,7 @@ static void Game_Render3D(double delta, float t) {
|
|||||||
/* Need to render again over top of translucent block, as the selection outline */
|
/* Need to render again over top of translucent block, as the selection outline */
|
||||||
/* is drawn without writing to the depth buffer */
|
/* is drawn without writing to the depth buffer */
|
||||||
if (Game_SelectedPos.Valid && !Game_HideGui && Blocks.Draw[Game_SelectedPos.block] == DRAW_TRANSLUCENT) {
|
if (Game_SelectedPos.Valid && !Game_HideGui && Blocks.Draw[Game_SelectedPos.block] == DRAW_TRANSLUCENT) {
|
||||||
PickedPosRenderer_Render();
|
PickedPosRenderer_Render(&Game_SelectedPos, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Selections_Render();
|
Selections_Render();
|
||||||
|
@ -142,7 +142,7 @@ CC_API void Model_DrawArmPart(struct ModelPart* part);
|
|||||||
|
|
||||||
/* Returns a pointer to the model whose name caselessly matches given name. */
|
/* Returns a pointer to the model whose name caselessly matches given name. */
|
||||||
CC_API struct Model* Model_Get(const String* name);
|
CC_API struct Model* Model_Get(const String* name);
|
||||||
/* Returns index of the model texture whose name caselessly matches given name. */
|
/* Returns a pointer to the model texture whose name caselessly matches given name. */
|
||||||
CC_API struct ModelTex* Model_GetTexture(const String* name);
|
CC_API struct ModelTex* Model_GetTexture(const String* name);
|
||||||
/* Adds a model to the list of models. (e.g. "skeleton") */
|
/* Adds a model to the list of models. (e.g. "skeleton") */
|
||||||
/* Models can be applied to entities to change their appearance. Use Entity_SetModel for that. */
|
/* Models can be applied to entities to change their appearance. Use Entity_SetModel for that. */
|
||||||
|
@ -10,19 +10,6 @@
|
|||||||
|
|
||||||
static GfxResourceID pickedPos_vb;
|
static GfxResourceID pickedPos_vb;
|
||||||
#define PICKEDPOS_NUM_VERTICES (16 * 6)
|
#define PICKEDPOS_NUM_VERTICES (16 * 6)
|
||||||
static VertexP3fC4b pickedPos_vertices[PICKEDPOS_NUM_VERTICES];
|
|
||||||
|
|
||||||
void PickedPosRenderer_Render(void) {
|
|
||||||
if (Gfx.LostContext) return;
|
|
||||||
|
|
||||||
Gfx_SetAlphaBlending(true);
|
|
||||||
Gfx_SetDepthWrite(false);
|
|
||||||
Gfx_SetVertexFormat(VERTEX_FORMAT_P3FC4B);
|
|
||||||
|
|
||||||
Gfx_UpdateDynamicVb_IndexedTris(pickedPos_vb, pickedPos_vertices, PICKEDPOS_NUM_VERTICES);
|
|
||||||
Gfx_SetDepthWrite(true);
|
|
||||||
Gfx_SetAlphaBlending(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PickedPos_Y(y)\
|
#define PickedPos_Y(y)\
|
||||||
0,y,1, 0,y,2, 1,y,2, 1,y,1,\
|
0,y,1, 0,y,2, 1,y,2, 1,y,1,\
|
||||||
@ -42,7 +29,7 @@ x,3,0, x,2,0, x,2,3, x,3,3,
|
|||||||
0,0,z, 0,1,z, 3,1,z, 3,0,z,\
|
0,0,z, 0,1,z, 3,1,z, 3,0,z,\
|
||||||
0,3,z, 0,2,z, 3,2,z, 3,3,z,
|
0,3,z, 0,2,z, 3,2,z, 3,3,z,
|
||||||
|
|
||||||
void PickedPosRenderer_Update(struct RayTracer* selected) {
|
static void BuildMesh(struct RayTracer* selected) {
|
||||||
static const cc_uint8 indices[288] = {
|
static const cc_uint8 indices[288] = {
|
||||||
PickedPos_Y(0) PickedPos_Y(3) /* YMin, YMax */
|
PickedPos_Y(0) PickedPos_Y(3) /* YMin, YMax */
|
||||||
PickedPos_X(0) PickedPos_X(3) /* XMin, XMax */
|
PickedPos_X(0) PickedPos_X(3) /* XMin, XMax */
|
||||||
@ -88,13 +75,29 @@ void PickedPosRenderer_Update(struct RayTracer* selected) {
|
|||||||
Vec3_Add1(&coords[3], &selected->Max, offset);
|
Vec3_Add1(&coords[3], &selected->Max, offset);
|
||||||
Vec3_Add1(&coords[2], &coords[3], -size);
|
Vec3_Add1(&coords[2], &coords[3], -size);
|
||||||
|
|
||||||
ptr = pickedPos_vertices;
|
ptr = (VertexP3fC4b*)Gfx_LockDynamicVb(pickedPos_vb, VERTEX_FORMAT_P3FC4B, PICKEDPOS_NUM_VERTICES);
|
||||||
for (i = 0; i < Array_Elems(indices); i += 3, ptr++) {
|
for (i = 0; i < Array_Elems(indices); i += 3, ptr++) {
|
||||||
ptr->X = coords[indices[i + 0]].X;
|
ptr->X = coords[indices[i + 0]].X;
|
||||||
ptr->Y = coords[indices[i + 1]].Y;
|
ptr->Y = coords[indices[i + 1]].Y;
|
||||||
ptr->Z = coords[indices[i + 2]].Z;
|
ptr->Z = coords[indices[i + 2]].Z;
|
||||||
ptr->Col = col;
|
ptr->Col = col;
|
||||||
}
|
}
|
||||||
|
Gfx_UnlockDynamicVb(pickedPos_vb);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PickedPosRenderer_Render(struct RayTracer* selected, cc_bool dirty) {
|
||||||
|
if (Gfx.LostContext) return;
|
||||||
|
|
||||||
|
Gfx_SetAlphaBlending(true);
|
||||||
|
Gfx_SetDepthWrite(false);
|
||||||
|
Gfx_SetVertexFormat(VERTEX_FORMAT_P3FC4B);
|
||||||
|
|
||||||
|
if (dirty) BuildMesh(selected);
|
||||||
|
else Gfx_BindDynamicVb(pickedPos_vb);
|
||||||
|
|
||||||
|
Gfx_DrawVb_IndexedTris(PICKEDPOS_NUM_VERTICES);
|
||||||
|
Gfx_SetDepthWrite(true);
|
||||||
|
Gfx_SetAlphaBlending(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,6 +8,5 @@ struct RayTracer;
|
|||||||
struct IGameComponent;
|
struct IGameComponent;
|
||||||
extern struct IGameComponent PickedPosRenderer_Component;
|
extern struct IGameComponent PickedPosRenderer_Component;
|
||||||
|
|
||||||
void PickedPosRenderer_Render(void);
|
void PickedPosRenderer_Render(struct RayTracer* selected, cc_bool dirty);
|
||||||
void PickedPosRenderer_Update(struct RayTracer* selected);
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user