mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 04:21:51 +00:00
[scene] Add a color map component
It's currently used only by the vulkan renderer, as it's the only renderer that can make good use of it for alias models, but now vulkan show shirt/pants colors (finally).
This commit is contained in:
parent
a28488d2e1
commit
387f17dc0c
6 changed files with 40 additions and 0 deletions
|
@ -99,6 +99,11 @@ typedef struct entqueue_s {
|
|||
int num_queues;
|
||||
} entqueue_t;
|
||||
|
||||
typedef struct colormap_s {
|
||||
byte top;
|
||||
byte bottom;
|
||||
} colormap_t;
|
||||
|
||||
#define ENTINLINE GNU89INLINE inline
|
||||
|
||||
entqueue_t *EntQueue_New (int num_queues);
|
||||
|
|
|
@ -47,6 +47,7 @@ enum scene_components {
|
|||
scene_renderer,
|
||||
scene_active,
|
||||
scene_old_origin, //XXX FIXME XXX should not be here
|
||||
scene_colormap,
|
||||
|
||||
//FIXME these should probably be private to the sw renderer (and in a
|
||||
//group, which needs to be implemented), but need to sort out a good
|
||||
|
|
|
@ -59,6 +59,13 @@ create_old_origin (void *_old_origin)
|
|||
*old_origin = (vec4f_t) {0, 0, 0, 1};
|
||||
}
|
||||
|
||||
static void
|
||||
create_colormap (void *_colormap)
|
||||
{
|
||||
colormap_t *colormap = _colormap;
|
||||
*colormap = (colormap_t) {1, 6};
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_visibility (void *_visibility)
|
||||
{
|
||||
|
@ -121,6 +128,11 @@ static const component_t scene_components[] = {
|
|||
.create = create_old_origin,
|
||||
.name = "old_origin",
|
||||
},
|
||||
[scene_colormap] = {
|
||||
.size = sizeof (colormap_t),
|
||||
.create = create_colormap,
|
||||
.name = "colormap",
|
||||
},
|
||||
|
||||
[scene_sw_matrix] = {
|
||||
.size = sizeof (mat4f_t),
|
||||
|
|
|
@ -163,6 +163,11 @@ Vulkan_DrawAlias (entity_t ent, qfv_renderframe_t *rFrame)
|
|||
}
|
||||
QuatCopy (renderer->colormod, constants.base_color);
|
||||
QuatCopy (skin->colors, constants.colors);
|
||||
if (Ent_HasComponent (ent.id, scene_colormap, ent.reg)) {
|
||||
colormap_t *colormap=Ent_GetComponent (ent.id, scene_colormap, ent.reg);
|
||||
constants.colors[0] = colormap->top * 16 + 8;
|
||||
constants.colors[1] = colormap->bottom * 16 + 8;
|
||||
}
|
||||
QuatZero (constants.fog);
|
||||
|
||||
emit_commands (aframe->cmdSet.a[QFV_aliasDepth],
|
||||
|
|
|
@ -246,6 +246,11 @@ CL_RelinkEntities (void)
|
|||
old->skinnum = new->skinnum;
|
||||
renderer->skinnum = new->skinnum;
|
||||
if (i <= cl.maxclients) {
|
||||
colormap_t colormap = {
|
||||
.top = cl.players[i - 1].topcolor,
|
||||
.bottom = cl.players[i - 1].bottomcolor,
|
||||
};
|
||||
Ent_SetComponent (ent.id, scene_colormap, ent.reg, &colormap);
|
||||
renderer->skin = mod_funcs->Skin_SetColormap (renderer->skin,
|
||||
i);
|
||||
mod_funcs->Skin_SetTranslation (i, cl.players[i - 1].topcolor,
|
||||
|
|
|
@ -218,6 +218,11 @@ CL_LinkPacketEntities (void)
|
|||
&& cl.players[new->colormap - 1].name->value[0]
|
||||
&& new->modelindex == cl_playerindex) {
|
||||
player_info_t *player = &cl.players[new->colormap - 1];
|
||||
colormap_t colormap = {
|
||||
.top = player->topcolor,
|
||||
.bottom = player->bottomcolor,
|
||||
};
|
||||
Ent_SetComponent (ent.id, scene_colormap, ent.reg, &colormap);
|
||||
renderer->skin
|
||||
= mod_funcs->Skin_SetSkin (renderer->skin, new->colormap,
|
||||
player->skinname->value);
|
||||
|
@ -226,6 +231,7 @@ CL_LinkPacketEntities (void)
|
|||
} else {
|
||||
renderer->skin = mod_funcs->Skin_SetColormap (renderer->skin,
|
||||
0);
|
||||
Ent_RemoveComponent (ent.id, scene_colormap, ent.reg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -462,6 +468,12 @@ CL_LinkPlayers (void)
|
|||
&& is_dead_body (&state->pls.es))
|
||||
continue;
|
||||
|
||||
colormap_t colormap = {
|
||||
.top = player->topcolor,
|
||||
.bottom = player->bottomcolor,
|
||||
};
|
||||
Ent_SetComponent (ent.id, scene_colormap, ent.reg, &colormap);
|
||||
|
||||
// predict only half the move to minimize overruns
|
||||
msec = 500 * (playertime - state->state_time);
|
||||
if (msec <= 0 || (!cl_predict_players) || cls.demoplayback2) {
|
||||
|
|
Loading…
Reference in a new issue