vkQuake2 doxygen  1.0 dev
vk_mesh.c File Reference
#include "vk_local.h"
#include "anorms.h"
#include "anormtab.h"

Go to the source code of this file.

Macros

#define NUMVERTEXNORMALS   162
 
#define SHADEDOT_QUANT   16
 

Typedefs

typedef float vec4_t[4]
 

Functions

void Vk_LerpVerts (int nverts, dtrivertx_t *v, dtrivertx_t *ov, dtrivertx_t *verts, float *lerp, float move[3], float frontv[3], float backv[3])
 
void Vk_DrawAliasFrameLerp (dmdl_t *paliashdr, float backlerp, image_t *skin, float *modelMatrix, int leftHandOffset, int translucentIdx)
 
void Vk_DrawAliasShadow (dmdl_t *paliashdr, int posenum, float *modelMatrix)
 
static qboolean R_CullAliasModel (vec3_t bbox[8], entity_t *e)
 
void R_DrawAliasModel (entity_t *e)
 

Variables

float r_avertexnormals [NUMVERTEXNORMALS][3]
 
static vec4_t s_lerped [MAX_VERTS]
 
vec3_t shadevector
 
float shadelight [3]
 
float r_avertexnormal_dots [SHADEDOT_QUANT][256]
 
float * shadedots = r_avertexnormal_dots[0]
 
float r_view_matrix [16]
 
float r_projection_matrix [16]
 
float r_viewproj_matrix [16]
 
static float r_vulkan_correction_dh [16]
 
vec3_t lightspot
 

Macro Definition Documentation

◆ NUMVERTEXNORMALS

#define NUMVERTEXNORMALS   162

Definition at line 33 of file vk_mesh.c.

◆ SHADEDOT_QUANT

#define SHADEDOT_QUANT   16

Definition at line 47 of file vk_mesh.c.

Typedef Documentation

◆ vec4_t

typedef float vec4_t[4]

Definition at line 39 of file vk_mesh.c.

Function Documentation

◆ R_CullAliasModel()

static qboolean R_CullAliasModel ( vec3_t  bbox[8],
entity_t e 
)
static

Definition at line 408 of file vk_mesh.c.

409 {
410  int i;
411  vec3_t mins, maxs;
412  dmdl_t *paliashdr;
413  vec3_t vectors[3];
414  vec3_t thismins, oldmins, thismaxs, oldmaxs;
415  daliasframe_t *pframe, *poldframe;
416  vec3_t angles;
417 
418  paliashdr = (dmdl_t *)currentmodel->extradata;
419 
420  if ( ( e->frame >= paliashdr->num_frames ) || ( e->frame < 0 ) )
421  {
422  ri.Con_Printf (PRINT_ALL, "R_CullAliasModel %s: no such frame %d\n",
423  currentmodel->name, e->frame);
424  e->frame = 0;
425  }
426  if ( ( e->oldframe >= paliashdr->num_frames ) || ( e->oldframe < 0 ) )
427  {
428  ri.Con_Printf (PRINT_ALL, "R_CullAliasModel %s: no such oldframe %d\n",
429  currentmodel->name, e->oldframe);
430  e->oldframe = 0;
431  }
432 
433  pframe = ( daliasframe_t * ) ( ( byte * ) paliashdr +
434  paliashdr->ofs_frames +
435  e->frame * paliashdr->framesize);
436 
437  poldframe = ( daliasframe_t * ) ( ( byte * ) paliashdr +
438  paliashdr->ofs_frames +
439  e->oldframe * paliashdr->framesize);
440 
441  /*
442  ** compute axially aligned mins and maxs
443  */
444  if ( pframe == poldframe )
445  {
446  for ( i = 0; i < 3; i++ )
447  {
448  mins[i] = pframe->translate[i];
449  maxs[i] = mins[i] + pframe->scale[i]*255;
450  }
451  }
452  else
453  {
454  for ( i = 0; i < 3; i++ )
455  {
456  thismins[i] = pframe->translate[i];
457  thismaxs[i] = thismins[i] + pframe->scale[i]*255;
458 
459  oldmins[i] = poldframe->translate[i];
460  oldmaxs[i] = oldmins[i] + poldframe->scale[i]*255;
461 
462  if ( thismins[i] < oldmins[i] )
463  mins[i] = thismins[i];
464  else
465  mins[i] = oldmins[i];
466 
467  if ( thismaxs[i] > oldmaxs[i] )
468  maxs[i] = thismaxs[i];
469  else
470  maxs[i] = oldmaxs[i];
471  }
472  }
473 
474  /*
475  ** compute a full bounding box
476  */
477  for ( i = 0; i < 8; i++ )
478  {
479  vec3_t tmp;
480 
481  if ( i & 1 )
482  tmp[0] = mins[0];
483  else
484  tmp[0] = maxs[0];
485 
486  if ( i & 2 )
487  tmp[1] = mins[1];
488  else
489  tmp[1] = maxs[1];
490 
491  if ( i & 4 )
492  tmp[2] = mins[2];
493  else
494  tmp[2] = maxs[2];
495 
496  VectorCopy( tmp, bbox[i] );
497  }
498 
499  /*
500  ** rotate the bounding box
501  */
502  VectorCopy( e->angles, angles );
503  angles[YAW] = -angles[YAW];
504  AngleVectors( angles, vectors[0], vectors[1], vectors[2] );
505 
506  for ( i = 0; i < 8; i++ )
507  {
508  vec3_t tmp;
509 
510  VectorCopy( bbox[i], tmp );
511 
512  bbox[i][0] = DotProduct( vectors[0], tmp );
513  bbox[i][1] = -DotProduct( vectors[1], tmp );
514  bbox[i][2] = DotProduct( vectors[2], tmp );
515 
516  VectorAdd( e->origin, bbox[i], bbox[i] );
517  }
518 
519  {
520  int p, f, aggregatemask = ~0;
521 
522  for ( p = 0; p < 8; p++ )
523  {
524  int mask = 0;
525 
526  for ( f = 0; f < 4; f++ )
527  {
528  float dp = DotProduct( frustum[f].normal, bbox[p] );
529 
530  if ( ( dp - frustum[f].dist ) < 0 )
531  {
532  mask |= ( 1 << f );
533  }
534  }
535 
536  aggregatemask &= mask;
537  }
538 
539  if ( aggregatemask )
540  {
541  return true;
542  }
543 
544  return false;
545  }
546 }

Referenced by R_DrawAliasModel().

◆ R_DrawAliasModel()

void R_DrawAliasModel ( entity_t e)

Definition at line 554 of file vk_mesh.c.

555 {
556  int i;
557  int leftHandOffset = 0;
558  dmdl_t *paliashdr;
559  float an;
560  vec3_t bbox[8];
561  image_t *skin;
562  float prev_viewproj[16];
563 
564  if ( !( e->flags & RF_WEAPONMODEL ) )
565  {
566  if ( R_CullAliasModel( bbox, e ) )
567  return;
568  }
569 
570  if ( e->flags & RF_WEAPONMODEL )
571  {
572  if ( r_lefthand->value == 2 )
573  return;
574  }
575 
576  paliashdr = (dmdl_t *)currentmodel->extradata;
577 
578  //
579  // get lighting information
580  //
581  // PMM - rewrote, reordered to handle new shells & mixing
582  // PMM - 3.20 code .. replaced with original way of doing it to keep mod authors happy
583  //
585  {
588  {
589  shadelight[0] = 0.56;
590  shadelight[1] = 0.59;
591  shadelight[2] = 0.45;
592  }
594  {
595  shadelight[0] = 0.9;
596  shadelight[1] = 0.7;
597  }
599  shadelight[0] = 1.0;
601  shadelight[1] = 1.0;
603  shadelight[2] = 1.0;
604  }
605  else if ( currententity->flags & RF_FULLBRIGHT )
606  {
607  for (i=0 ; i<3 ; i++)
608  shadelight[i] = 1.0;
609  }
610  else
611  {
613 
614  // player lighting hack for communication back to server
615  // big hack!
617  {
618  // pick the greatest component, which should be the same
619  // as the mono value returned by software
620  if (shadelight[0] > shadelight[1])
621  {
622  if (shadelight[0] > shadelight[2])
623  r_lightlevel->value = 150*shadelight[0];
624  else
625  r_lightlevel->value = 150*shadelight[2];
626  }
627  else
628  {
629  if (shadelight[1] > shadelight[2])
630  r_lightlevel->value = 150*shadelight[1];
631  else
632  r_lightlevel->value = 150*shadelight[2];
633  }
634  }
635  }
636 
638  {
639  for (i=0 ; i<3 ; i++)
640  if (shadelight[i] > 0.1)
641  break;
642  if (i == 3)
643  {
644  shadelight[0] = 0.1;
645  shadelight[1] = 0.1;
646  shadelight[2] = 0.1;
647  }
648  }
649 
650  if ( currententity->flags & RF_GLOW )
651  { // bonus items will pulse with time
652  float scale;
653  float min;
654 
655  scale = 0.1 * sin(r_newrefdef.time*7);
656  for (i=0 ; i<3 ; i++)
657  {
658  min = shadelight[i] * 0.8;
659  shadelight[i] += scale;
660  if (shadelight[i] < min)
661  shadelight[i] = min;
662  }
663  }
664 
665 // =================
666 // PGM ir goggles color override
668  {
669  shadelight[0] = 1.0;
670  shadelight[1] = 0.0;
671  shadelight[2] = 0.0;
672  }
673 // PGM
674 // =================
675 
677 
678  an = currententity->angles[1]/180*M_PI;
679  shadevector[0] = cos(-an);
680  shadevector[1] = sin(-an);
681  shadevector[2] = 1;
683 
684  //
685  // locate the proper data
686  //
687 
688  c_alias_polys += paliashdr->num_tris;
689 
690  //
691  // draw all the triangles
692  //
693  if (currententity->flags & RF_DEPTHHACK || r_newrefdef.rdflags & RDF_NOWORLDMODEL) { // hack the depth range to prevent view model from poking into walls
694  extern float r_proj_aspect, r_proj_fovy;
695  // use different range for player setup screen so it doesn't collide with the viewmodel
698 
699  memcpy(prev_viewproj, r_viewproj_matrix, sizeof(r_viewproj_matrix));
702  vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline.layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(r_viewproj_matrix), r_viewproj_matrix);
703  }
704 
705  if ( ( currententity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ) )
706  {
707  Mat_Scale(r_viewproj_matrix, -1.f, 1.f, 1.f);
708  vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline.layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(r_viewproj_matrix), r_viewproj_matrix);
709  leftHandOffset = 2;
710  }
711 
712  e->angles[PITCH] = -e->angles[PITCH]; // sigh.
713  float model[16];
714  Mat_Identity(model);
715  R_RotateForEntity (e, model);
716  e->angles[PITCH] = -e->angles[PITCH]; // sigh.
717 
718  // select skin
719  if (currententity->skin)
720  skin = currententity->skin; // custom player skin
721  else
722  {
724  skin = currentmodel->skins[0];
725  else
726  {
728  if (!skin)
729  skin = currentmodel->skins[0];
730  }
731  }
732  if (!skin)
733  skin = r_notexture; // fallback...
734 
735  // draw it
736  if ( (currententity->frame >= paliashdr->num_frames)
737  || (currententity->frame < 0) )
738  {
739  ri.Con_Printf (PRINT_ALL, "R_DrawAliasModel %s: no such frame %d\n",
741  currententity->frame = 0;
742  currententity->oldframe = 0;
743  }
744 
745  if ( (currententity->oldframe >= paliashdr->num_frames)
746  || (currententity->oldframe < 0))
747  {
748  ri.Con_Printf (PRINT_ALL, "R_DrawAliasModel %s: no such oldframe %d\n",
750  currententity->frame = 0;
751  currententity->oldframe = 0;
752  }
753 
754  if ( !r_lerpmodels->value )
755  currententity->backlerp = 0;
756  Vk_DrawAliasFrameLerp (paliashdr, currententity->backlerp, skin, model, leftHandOffset, currententity->flags & RF_TRANSLUCENT ? 1 : 0);
757 
758  if ( ( currententity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ) )
759  {
760  Mat_Scale(r_viewproj_matrix, -1.f, 1.f, 1.f);
761  vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline.layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(r_viewproj_matrix), r_viewproj_matrix);
762  }
763 
765  {
766  memcpy(r_viewproj_matrix, prev_viewproj, sizeof(prev_viewproj));
767  vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline.layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(r_viewproj_matrix), r_viewproj_matrix);
768  }
769 
771  {
772  float model[16];
773  Mat_Identity(model);
774  R_RotateForEntity(e, model);
775  Vk_DrawAliasShadow (paliashdr, currententity->frame, model);
776  }
777 }

Referenced by R_DrawEntitiesOnList().

◆ Vk_DrawAliasFrameLerp()

void Vk_DrawAliasFrameLerp ( dmdl_t paliashdr,
float  backlerp,
image_t skin,
float *  modelMatrix,
int  leftHandOffset,
int  translucentIdx 
)

Definition at line 101 of file vk_mesh.c.

102 {
103  float l;
104  daliasframe_t *frame, *oldframe;
105  dtrivertx_t *v, *ov, *verts;
106  int *order;
107  int count;
108  float frontlerp;
109  float alpha;
110  vec3_t move, delta, vectors[3];
111  vec3_t frontv, backv;
112  int i;
113  int index_xyz;
114  float *lerp;
115 
116  frame = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
117  + currententity->frame * paliashdr->framesize);
118  verts = v = frame->verts;
119 
120  oldframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
121  + currententity->oldframe * paliashdr->framesize);
122  ov = oldframe->verts;
123 
124  order = (int *)((byte *)paliashdr + paliashdr->ofs_glcmds);
125 
128  else
129  alpha = 1.0;
130 
131  frontlerp = 1.0 - backlerp;
132 
133  // move should be the delta back to the previous frame * backlerp
135  AngleVectors (currententity->angles, vectors[0], vectors[1], vectors[2]);
136 
137  move[0] = DotProduct (delta, vectors[0]); // forward
138  move[1] = -DotProduct (delta, vectors[1]); // left
139  move[2] = DotProduct (delta, vectors[2]); // up
140 
141  VectorAdd (move, oldframe->translate, move);
142 
143  for (i=0 ; i<3 ; i++)
144  {
145  move[i] = backlerp*move[i] + frontlerp*frame->translate[i];
146  }
147 
148  for (i=0 ; i<3 ; i++)
149  {
150  frontv[i] = frontlerp*frame->scale[i];
151  backv[i] = backlerp*oldframe->scale[i];
152  }
153 
154  lerp = s_lerped[0];
155 
156  Vk_LerpVerts( paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv );
157 
158  enum {
159  TRIANGLE_STRIP = 0,
160  TRIANGLE_FAN = 1
161  } pipelineIdx;
162 
163  typedef struct {
164  float vertex[3];
165  float color[4];
166  float texCoord[2];
167  } modelvert;
168 
169  int vertCounts[2] = { 0, 0 };
170  static modelvert vertList[2][MAX_VERTS];
171  int pipeCounters[2] = { 0, 0 };
172  VkDeviceSize maxTriangleFanIdxCnt = 0;
173 
174  static struct {
175  int vertexCount;
176  int firstVertex;
177  } drawInfo[2][MAX_VERTS];
178 
179  drawInfo[0][0].firstVertex = 0;
180  drawInfo[1][0].firstVertex = 0;
181 
182  struct {
183  float model[16];
184  int textured;
185  } meshUbo;
186 
187  while (1)
188  {
189  // get the vertex count and primitive type
190  count = *order++;
191  if (!count)
192  break; // done
193  if (count < 0)
194  {
195  count = -count;
196  pipelineIdx = TRIANGLE_FAN;
197  }
198  else
199  {
200  pipelineIdx = TRIANGLE_STRIP;
201  }
202 
203  drawInfo[pipelineIdx][pipeCounters[pipelineIdx]].vertexCount = count;
204  maxTriangleFanIdxCnt = max(maxTriangleFanIdxCnt, ((count - 2) * 3));
205 
207  {
208  meshUbo.textured = 0;
209  do
210  {
211  int vertIdx = vertCounts[pipelineIdx];
212  // unused in this case, since texturing is disabled
213  vertList[pipelineIdx][vertIdx].texCoord[0] = 0.f;
214  vertList[pipelineIdx][vertIdx].texCoord[1] = 0.f;
215  index_xyz = order[2];
216  order += 3;
217 
218  vertList[pipelineIdx][vertIdx].color[0] = shadelight[0];
219  vertList[pipelineIdx][vertIdx].color[1] = shadelight[1];
220  vertList[pipelineIdx][vertIdx].color[2] = shadelight[2];
221  vertList[pipelineIdx][vertIdx].color[3] = alpha;
222 
223  vertList[pipelineIdx][vertIdx].vertex[0] = s_lerped[index_xyz][0];
224  vertList[pipelineIdx][vertIdx].vertex[1] = s_lerped[index_xyz][1];
225  vertList[pipelineIdx][vertIdx].vertex[2] = s_lerped[index_xyz][2];
226  vertCounts[pipelineIdx]++;
227  } while (--count);
228  }
229  else
230  {
231  meshUbo.textured = 1;
232  do
233  {
234  int vertIdx = vertCounts[pipelineIdx];
235  // texture coordinates come from the draw list
236  vertList[pipelineIdx][vertIdx].texCoord[0] = ((float *)order)[0];
237  vertList[pipelineIdx][vertIdx].texCoord[1] = ((float *)order)[1];
238  index_xyz = order[2];
239  order += 3;
240 
241  // normals and vertexes come from the frame list
242  l = shadedots[verts[index_xyz].lightnormalindex];
243 
244  vertList[pipelineIdx][vertIdx].color[0] = l * shadelight[0];
245  vertList[pipelineIdx][vertIdx].color[1] = l * shadelight[1];
246  vertList[pipelineIdx][vertIdx].color[2] = l * shadelight[2];
247  vertList[pipelineIdx][vertIdx].color[3] = alpha;
248 
249  vertList[pipelineIdx][vertIdx].vertex[0] = s_lerped[index_xyz][0];
250  vertList[pipelineIdx][vertIdx].vertex[1] = s_lerped[index_xyz][1];
251  vertList[pipelineIdx][vertIdx].vertex[2] = s_lerped[index_xyz][2];
252  vertCounts[pipelineIdx]++;
253  } while (--count);
254  }
255 
256  pipeCounters[pipelineIdx]++;
257  drawInfo[pipelineIdx][pipeCounters[pipelineIdx]].firstVertex = vertCounts[pipelineIdx];
258  }
259 
260  uint32_t uboOffset;
261  VkDescriptorSet uboDescriptorSet;
262  uint8_t *uboData = QVk_GetUniformBuffer(sizeof(meshUbo), &uboOffset, &uboDescriptorSet);
263  memcpy(meshUbo.model, modelMatrix, sizeof(float) * 16);
264  memcpy(uboData, &meshUbo, sizeof(meshUbo));
265 
266  // player configuration screen model is using the UI renderpass
268  // non-depth write alias models don't occur with RF_WEAPONMODEL set, so no need for additional left-handed pipelines
271  for (int p = 0; p < 2; p++)
272  {
273  VkDeviceSize vaoSize = sizeof(modelvert) * vertCounts[p];
274  VkBuffer vbo;
275  VkDeviceSize vboOffset;
276  uint8_t *vertData = QVk_GetVertexBuffer(vaoSize, &vbo, &vboOffset);
277  memcpy(vertData, vertList[p], vaoSize);
278 
279  QVk_BindPipeline(&pipelines[translucentIdx][p + leftHandOffset]);
280  VkDescriptorSet descriptorSets[] = { skin->vk_texture.descriptorSet, uboDescriptorSet };
281  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines[translucentIdx][p + leftHandOffset].layout, 0, 2, descriptorSets, 1, &uboOffset);
282  vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
283 
284  if (p == TRIANGLE_STRIP)
285  {
286  for (i = 0; i < pipeCounters[p]; i++)
287  {
288  vkCmdDraw(vk_activeCmdbuffer, drawInfo[p][i].vertexCount, 1, drawInfo[p][i].firstVertex, 0);
289  }
290  }
291  else
292  {
293  vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleFanIbo(maxTriangleFanIdxCnt), 0, VK_INDEX_TYPE_UINT16);
294 
295  for (i = 0; i < pipeCounters[p]; i++)
296  {
297  vkCmdDrawIndexed(vk_activeCmdbuffer, (drawInfo[p][i].vertexCount - 2) * 3, 1, 0, drawInfo[p][i].firstVertex, 0);
298  }
299  }
300  }
301 }

Referenced by R_DrawAliasModel().

◆ Vk_DrawAliasShadow()

void Vk_DrawAliasShadow ( dmdl_t paliashdr,
int  posenum,
float *  modelMatrix 
)

Definition at line 311 of file vk_mesh.c.

312 {
313  dtrivertx_t *verts;
314  int *order;
315  vec3_t point;
316  float height, lheight;
317  int count;
318  int i;
319  daliasframe_t *frame;
321 
322  enum {
323  TRIANGLE_STRIP = 0,
324  TRIANGLE_FAN = 1
325  } pipelineIdx;
326 
327  lheight = currententity->origin[2] - lightspot[2];
328 
329  frame = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
330  + currententity->frame * paliashdr->framesize);
331  verts = frame->verts;
332 
333  height = 0;
334 
335  order = (int *)((byte *)paliashdr + paliashdr->ofs_glcmds);
336 
337  height = -lheight + 1.0;
338 
339  uint32_t uboOffset;
340  VkDescriptorSet uboDescriptorSet;
341  uint8_t *uboData = QVk_GetUniformBuffer(sizeof(float) * 16, &uboOffset, &uboDescriptorSet);
342  memcpy(uboData, modelMatrix, sizeof(float) * 16);
343 
344  static vec3_t shadowverts[MAX_VERTS];
345  while (1)
346  {
347  i = 0;
348  // get the vertex count and primitive type
349  count = *order++;
350  if (!count)
351  break; // done
352  if (count < 0)
353  {
354  count = -count;
355  pipelineIdx = TRIANGLE_FAN;
356  }
357  else
358  {
359  pipelineIdx = TRIANGLE_STRIP;
360  }
361 
362  do
363  {
364  // normals and vertexes come from the frame list
365  memcpy( point, s_lerped[order[2]], sizeof( point ) );
366 
367  point[0] -= shadevector[0]*(point[2]+lheight);
368  point[1] -= shadevector[1]*(point[2]+lheight);
369  point[2] = height;
370 
371  shadowverts[i][0] = point[0];
372  shadowverts[i][1] = point[1];
373  shadowverts[i][2] = point[2];
374 
375  order += 3;
376  i++;
377  } while (--count);
378 
379  if (i > 0)
380  {
381  VkDeviceSize vaoSize = sizeof(vec3_t) * i;
382  VkBuffer vbo;
383  VkDeviceSize vboOffset;
384  uint8_t *vertData = QVk_GetVertexBuffer(vaoSize, &vbo, &vboOffset);
385  memcpy(vertData, shadowverts, vaoSize);
386 
387  QVk_BindPipeline(&pipelines[pipelineIdx]);
388  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines[pipelineIdx].layout, 0, 1, &uboDescriptorSet, 1, &uboOffset);
389  vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
390 
391  if (pipelineIdx == TRIANGLE_STRIP)
392  {
393  vkCmdDraw(vk_activeCmdbuffer, i, 1, 0, 0);
394  }
395  else
396  {
397  vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleFanIbo((i - 2) * 3), 0, VK_INDEX_TYPE_UINT16);
398  vkCmdDrawIndexed(vk_activeCmdbuffer, (i - 2) * 3, 1, 0, 0, 0);
399  }
400  }
401  }
402 }

Referenced by R_DrawAliasModel().

◆ Vk_LerpVerts()

void Vk_LerpVerts ( int  nverts,
dtrivertx_t v,
dtrivertx_t ov,
dtrivertx_t verts,
float *  lerp,
float  move[3],
float  frontv[3],
float  backv[3] 
)

Definition at line 65 of file vk_mesh.c.

66 {
67  int i;
68 
69  //PMM -- added RF_SHELL_DOUBLE, RF_SHELL_HALF_DAM
71  {
72  for (i=0 ; i < nverts; i++, v++, ov++, lerp+=4 )
73  {
74  float *normal = r_avertexnormals[verts[i].lightnormalindex];
75 
76  lerp[0] = move[0] + ov->v[0]*backv[0] + v->v[0]*frontv[0] + normal[0] * POWERSUIT_SCALE;
77  lerp[1] = move[1] + ov->v[1]*backv[1] + v->v[1]*frontv[1] + normal[1] * POWERSUIT_SCALE;
78  lerp[2] = move[2] + ov->v[2]*backv[2] + v->v[2]*frontv[2] + normal[2] * POWERSUIT_SCALE;
79  }
80  }
81  else
82  {
83  for (i=0 ; i < nverts; i++, v++, ov++, lerp+=4)
84  {
85  lerp[0] = move[0] + ov->v[0]*backv[0] + v->v[0]*frontv[0];
86  lerp[1] = move[1] + ov->v[1]*backv[1] + v->v[1]*frontv[1];
87  lerp[2] = move[2] + ov->v[2]*backv[2] + v->v[2]*frontv[2];
88  }
89  }
90 
91 }

Referenced by Vk_DrawAliasFrameLerp().

Variable Documentation

◆ lightspot

vec3_t lightspot

Definition at line 118 of file r_light.c.

Referenced by RecursiveLightPoint(), RecursiveLightPointColor(), and Vk_DrawAliasShadow().

◆ r_avertexnormal_dots

float r_avertexnormal_dots[SHADEDOT_QUANT][256]
Initial value:
=
# 49 "C:/entry/dev/vq2/src/ref_vk/vk_mesh.c" 2

Definition at line 48 of file vk_mesh.c.

Referenced by R_DrawAliasModel().

◆ r_avertexnormals

float r_avertexnormals[NUMVERTEXNORMALS][3]
Initial value:
= {
}

Definition at line 35 of file vk_mesh.c.

Referenced by Vk_LerpVerts().

◆ r_projection_matrix

float r_projection_matrix[16]

Definition at line 59 of file vk_rmain.c.

Referenced by R_DrawAliasModel(), and R_SetupVulkan().

◆ r_view_matrix

float r_view_matrix[16]

Definition at line 63 of file vk_rmain.c.

Referenced by R_DrawAliasModel(), and R_SetupVulkan().

◆ r_viewproj_matrix

float r_viewproj_matrix[16]

Definition at line 64 of file vk_rmain.c.

Referenced by R_DrawAliasModel(), R_DrawSpriteModel(), and R_SetupVulkan().

◆ r_vulkan_correction_dh

float r_vulkan_correction_dh[16]
static
Initial value:
= { 1.f, 0.f, 0.f, 0.f,
0.f, -1.f, 0.f, 0.f,
0.f, 0.f, .3f, 0.f,
0.f, 0.f, .3f, 1.f
}

Definition at line 59 of file vk_mesh.c.

Referenced by R_DrawAliasModel().

◆ s_lerped

vec4_t s_lerped[MAX_VERTS]
static

Definition at line 41 of file vk_mesh.c.

Referenced by Vk_DrawAliasFrameLerp(), and Vk_DrawAliasShadow().

◆ shadedots

float* shadedots = r_avertexnormal_dots[0]

Definition at line 52 of file vk_mesh.c.

Referenced by R_DrawAliasModel(), and Vk_DrawAliasFrameLerp().

◆ shadelight

float shadelight[3]

Definition at line 44 of file vk_mesh.c.

Referenced by R_DrawAliasModel(), and Vk_DrawAliasFrameLerp().

◆ shadevector

vec3_t shadevector

Definition at line 43 of file vk_mesh.c.

Referenced by R_DrawAliasModel(), and Vk_DrawAliasShadow().

s_lerped
static vec4_t s_lerped[MAX_VERTS]
Definition: vk_mesh.c:41
RF_TRANSLUCENT
#define RF_TRANSLUCENT
Definition: q_shared.h:604
vk_shadows
cvar_t * vk_shadows
Definition: vk_rmain.c:103
dtrivertx_t::lightnormalindex
byte lightnormalindex
Definition: qfiles.h:110
RF_SHELL_RED
#define RF_SHELL_RED
Definition: q_shared.h:609
dmdl_t::ofs_glcmds
int ofs_glcmds
Definition: qfiles.h:157
height
GLsizei height
Definition: qgl_win.c:69
currentmodel
model_t * currentmodel
Definition: r_main.c:39
entity_s::skin
struct image_s * skin
Definition: ref.h:75
YAW
#define YAW
Definition: q_shared.h:73
entity_s::origin
float origin[3]
Definition: ref.h:57
RF_IR_VISIBLE
#define RF_IR_VISIBLE
Definition: q_shared.h:614
daliasframe_t::scale
float scale[3]
Definition: qfiles.h:121
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
RF_MINLIGHT
#define RF_MINLIGHT
Definition: q_shared.h:599
VectorSubtract
#define VectorSubtract(a, b, c)
Definition: q_shared.h:163
RF_SHELL_HALF_DAM
#define RF_SHELL_HALF_DAM
Definition: q_shared.h:616
Vk_DrawAliasShadow
void Vk_DrawAliasShadow(dmdl_t *paliashdr, int posenum, float *modelMatrix)
Definition: vk_mesh.c:311
r_notexture
image_t * r_notexture
Definition: gl_rmain.c:44
ri
refimport_t ri
Definition: r_main.c:25
qvkpipeline_t
Definition: qvk.h:152
RF_SHELL_GREEN
#define RF_SHELL_GREEN
Definition: q_shared.h:610
vk_drawLefthandModelPipelineFan
qvkpipeline_t vk_drawLefthandModelPipelineFan
Definition: vk_common.c:145
v
GLdouble v
Definition: qgl_win.c:143
dmdl_t::num_tris
int num_tris
Definition: qfiles.h:149
Mat_Perspective
void Mat_Perspective(float *matrix, float *correction_matrix, float fovy, float aspect, float zNear, float zFar)
Definition: vk_rmain.c:756
frustum
cplane_t frustum[4]
Definition: gl_rmain.c:50
R_LightPoint
void R_LightPoint(vec3_t p, vec3_t color)
Definition: r_light.c:226
Vk_DrawAliasFrameLerp
void Vk_DrawAliasFrameLerp(dmdl_t *paliashdr, float backlerp, image_t *skin, float *modelMatrix, int leftHandOffset, int translucentIdx)
Definition: vk_mesh.c:101
QVk_GetTriangleFanIbo
VkBuffer QVk_GetTriangleFanIbo(VkDeviceSize indexCount)
Definition: vk_common.c:2198
entity_s::skinnum
int skinnum
Definition: ref.h:70
VectorClear
#define VectorClear(a)
Definition: q_shared.h:166
i
int i
Definition: q_shared.c:305
Mat_Mul
void Mat_Mul(float *m1, float *m2, float *res)
Definition: vk_rmain.c:695
r_projection_matrix
float r_projection_matrix[16]
Definition: vk_rmain.c:59
dtrivertx_t
Definition: qfiles.h:107
PITCH
#define PITCH
Definition: q_shared.h:72
refdef_t::rdflags
int rdflags
Definition: ref.h:110
order
GLdouble GLdouble GLint GLint order
Definition: qgl_win.c:225
vk_drawModelPipelineFan
qvkpipeline_t vk_drawModelPipelineFan[2]
Definition: vk_common.c:141
entity_s::flags
int flags
Definition: ref.h:76
M_PI
#define M_PI
Definition: q_shared.h:142
currententity
entity_t * currententity
Definition: r_bsp.c:28
vk_drawNoDepthModelPipelineFan
qvkpipeline_t vk_drawNoDepthModelPipelineFan
Definition: vk_common.c:143
vk_drawLefthandModelPipelineStrip
qvkpipeline_t vk_drawLefthandModelPipelineStrip
Definition: vk_common.c:144
r_vulkan_correction_dh
static float r_vulkan_correction_dh[16]
Definition: vk_mesh.c:59
r_lefthand
cvar_t * r_lefthand
Definition: r_main.c:117
vk_drawTexQuadPipeline
qvkpipeline_t vk_drawTexQuadPipeline
Definition: vk_common.c:138
model_s::extradata
void * extradata
Definition: r_model.h:235
vk_drawNoDepthModelPipelineStrip
qvkpipeline_t vk_drawNoDepthModelPipelineStrip
Definition: vk_common.c:142
QVk_GetVertexBuffer
uint8_t * QVk_GetVertexBuffer(VkDeviceSize size, VkBuffer *dstBuffer, VkDeviceSize *dstOffset)
Definition: vk_common.c:2019
Mat_Identity
void Mat_Identity(float *matrix)
Definition: vk_rmain.c:675
AngleVectors
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Definition: q_shared.c:93
RF_WEAPONMODEL
#define RF_WEAPONMODEL
Definition: q_shared.h:601
refimport_t::Con_Printf
void(* Con_Printf)(int print_level, char *str,...)
Definition: ref.h:202
PRINT_ALL
#define PRINT_ALL
Definition: qcommon.h:751
RDF_NOWORLDMODEL
#define RDF_NOWORLDMODEL
Definition: q_shared.h:622
skin
cvar_t * skin
Definition: cl_main.c:80
entity_s::alpha
float alpha
Definition: ref.h:73
dmdl_t::ofs_frames
int ofs_frames
Definition: qfiles.h:156
Vk_LerpVerts
void Vk_LerpVerts(int nverts, dtrivertx_t *v, dtrivertx_t *ov, dtrivertx_t *verts, float *lerp, float move[3], float frontv[3], float backv[3])
Definition: vk_mesh.c:65
r_lerpmodels
cvar_t * r_lerpmodels
Definition: r_main.c:138
r_proj_fovy
float r_proj_fovy
Definition: vk_rmain.c:62
RF_DEPTHHACK
#define RF_DEPTHHACK
Definition: q_shared.h:603
QVk_GetUniformBuffer
uint8_t * QVk_GetUniformBuffer(VkDeviceSize size, uint32_t *dstOffset, VkDescriptorSet *dstUboDescriptorSet)
Definition: vk_common.c:2100
RDF_IRGOGGLES
#define RDF_IRGOGGLES
Definition: q_shared.h:625
min
#define min(a, b)
Definition: vk_local.h:72
vk_activeCmdbuffer
VkCommandBuffer vk_activeCmdbuffer
Definition: vk_common.c:127
entity_s::oldframe
int oldframe
Definition: ref.h:64
RF_SHELL_DOUBLE
#define RF_SHELL_DOUBLE
Definition: q_shared.h:615
r_newrefdef
refdef_t r_newrefdef
Definition: r_main.c:38
DotProduct
#define DotProduct(x, y)
Definition: q_shared.h:162
dmdl_t::num_xyz
int num_xyz
Definition: qfiles.h:147
cvar_s::value
float value
Definition: q_shared.h:331
entity_s::backlerp
float backlerp
Definition: ref.h:69
r_viewproj_matrix
float r_viewproj_matrix[16]
Definition: vk_rmain.c:64
VectorNormalize
vec_t VectorNormalize(vec3_t v)
Definition: q_shared.c:681
dmdl_t::framesize
int framesize
Definition: qfiles.h:144
refdef_t::time
float time
Definition: ref.h:109
RF_GLOW
#define RF_GLOW
Definition: q_shared.h:608
daliasframe_t::translate
float translate[3]
Definition: qfiles.h:122
lightspot
vec3_t lightspot
Definition: r_light.c:118
alpha
GLfloat GLfloat GLfloat alpha
Definition: qgl_win.c:74
r_avertexnormal_dots
float r_avertexnormal_dots[SHADEDOT_QUANT][256]
Definition: vk_mesh.c:48
MAX_MD2SKINS
#define MAX_MD2SKINS
Definition: qfiles.h:92
r_lightlevel
cvar_t * r_lightlevel
Definition: r_main.c:142
qvkpipeline_t::layout
VkPipelineLayout layout
Definition: qvk.h:154
R_CullAliasModel
static qboolean R_CullAliasModel(vec3_t bbox[8], entity_t *e)
Definition: vk_mesh.c:408
r_proj_aspect
float r_proj_aspect
Definition: vk_rmain.c:60
VectorAdd
#define VectorAdd(a, b, c)
Definition: q_shared.h:164
entity_s::frame
int frame
Definition: ref.h:58
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:165
vk_shadowsPipelineStrip
qvkpipeline_t vk_shadowsPipelineStrip
Definition: vk_common.c:157
model_s::skins
image_t * skins[MAX_MD2SKINS]
Definition: r_model.h:234
vk_drawModelPipelineStrip
qvkpipeline_t vk_drawModelPipelineStrip[2]
Definition: vk_common.c:140
r_view_matrix
float r_view_matrix[16]
Definition: vk_rmain.c:63
RP_UI
@ RP_UI
Definition: qvk.h:197
MAX_VERTS
#define MAX_VERTS
Definition: qfiles.h:90
c_alias_polys
int c_alias_polys
Definition: gl_local.h:157
model_s::name
char name[MAX_QPATH]
Definition: r_model.h:173
QVk_BindPipeline
void QVk_BindPipeline(qvkpipeline_t *pipeline)
Definition: vk_common.c:2284
shadedots
float * shadedots
Definition: vk_mesh.c:52
POWERSUIT_SCALE
#define POWERSUIT_SCALE
Definition: ref.h:30
RF_FULLBRIGHT
#define RF_FULLBRIGHT
Definition: q_shared.h:602
Mat_Scale
void Mat_Scale(float *matrix, float x, float y, float z)
Definition: vk_rmain.c:745
daliasframe_t
Definition: qfiles.h:119
shadevector
vec3_t shadevector
Definition: vk_mesh.c:43
daliasframe_t::verts
dtrivertx_t verts[1]
Definition: qfiles.h:124
SHADEDOT_QUANT
#define SHADEDOT_QUANT
Definition: vk_mesh.c:47
vk_shadowsPipelineFan
qvkpipeline_t vk_shadowsPipelineFan
Definition: vk_common.c:158
R_RotateForEntity
void R_RotateForEntity(entity_t *e)
Definition: gl_rmain.c:165
RF_SHELL_BLUE
#define RF_SHELL_BLUE
Definition: q_shared.h:611
image_s
Definition: r_local.h:71
mask
GLint GLuint mask
Definition: qgl_win.c:317
RP_WORLD
@ RP_WORLD
Definition: qvk.h:196
r_avertexnormals
float r_avertexnormals[NUMVERTEXNORMALS][3]
Definition: vk_mesh.c:35
max
#define max(a, b)
Definition: vk_local.h:75
entity_s::oldorigin
float oldorigin[3]
Definition: ref.h:63
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:134
dmdl_t
Definition: qfiles.h:137
entity_s::angles
float angles[3]
Definition: ref.h:52
count
GLint GLsizei count
Definition: qgl_win.c:128
dmdl_t::num_frames
int num_frames
Definition: qfiles.h:151
shadelight
float shadelight[3]
Definition: vk_mesh.c:44