[vulkan] Set entity render id correctly

It was being set to -1 unconditionally due to forgetting to use id.
However, I decided I didn't like reusing the id var and did some
renaming while I was at it.
This commit is contained in:
Bill Currie 2022-10-23 23:38:21 +09:00
parent 9f9e21f1dc
commit f37c31a2dc

View file

@ -75,21 +75,20 @@ Vulkan_Scene_AddEntity (vulkan_ctx_t *ctx, entity_t entity)
scnframe_t *sframe = &sctx->frames.a[ctx->curFrame]; scnframe_t *sframe = &sctx->frames.a[ctx->curFrame];
entdata_t *entdata = 0; entdata_t *entdata = 0;
int render_id = -1;
//lock //lock
int id = Ent_Index (entity.id + 1);//nullent -> 0 int ent_id = Ent_Index (entity.id + 1);//nullent -> 0
if (!set_is_member (sframe->pooled_entities, id)) { if (!set_is_member (sframe->pooled_entities, ent_id)) {
if (sframe->entity_pool.size < sframe->entity_pool.maxSize) { if (sframe->entity_pool.size < sframe->entity_pool.maxSize) {
set_add (sframe->pooled_entities, id); set_add (sframe->pooled_entities, ent_id);
id = sframe->entity_pool.size++; render_id = sframe->entity_pool.size++;
entdata = sframe->entity_pool.a + id; entdata = sframe->entity_pool.a + render_id;
} else {
id = -1;
} }
} }
if (Entity_Valid (entity)) { if (Entity_Valid (entity)) {
renderer_t *renderer = Ent_GetComponent (entity.id, scene_renderer, renderer_t *renderer = Ent_GetComponent (entity.id, scene_renderer,
r_refdef.scene->reg); entity.reg);
renderer->render_id = -1; renderer->render_id = render_id;
} }
//unlock //unlock
if (entdata) { if (entdata) {
@ -98,7 +97,7 @@ Vulkan_Scene_AddEntity (vulkan_ctx_t *ctx, entity_t entity)
if (Entity_Valid (entity)) { //FIXME give world entity an entity :P if (Entity_Valid (entity)) { //FIXME give world entity an entity :P
transform_t transform = Entity_Transform (entity); transform_t transform = Entity_Transform (entity);
renderer_t *renderer = Ent_GetComponent (entity.id, scene_renderer, renderer_t *renderer = Ent_GetComponent (entity.id, scene_renderer,
r_refdef.scene->reg); entity.reg);
mat4ftranspose (f, Transform_GetWorldMatrixPtr (transform)); mat4ftranspose (f, Transform_GetWorldMatrixPtr (transform));
entdata->xform[0] = f[0]; entdata->xform[0] = f[0];
entdata->xform[1] = f[1]; entdata->xform[1] = f[1];
@ -112,7 +111,7 @@ Vulkan_Scene_AddEntity (vulkan_ctx_t *ctx, entity_t entity)
} }
entdata->color = color; entdata->color = color;
} }
return id; return render_id;
} }
void void