Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vertmodel.hpp
Go to the documentation of this file.
1 
2 #pragma once
4 #include "inexor/shared/geom.hpp"
5 
7 {
8  struct vert { vec pos, norm; };
9  struct vvert { vec pos; vec2 tc; };
10  struct vvertn : vvert { vec norm; };
11  struct vvertbump : vvert { squat tangent; };
12  struct tcvert { vec2 tc; };
13  struct bumpvert { vec4 tangent; };
14  struct tri { ushort vert[3]; };
15 
17  {
20  int millis;
21 
22  vbocacheentry() : vbuf(0) { as.cur.fr1 = as.prev.fr1 = -1; }
23  };
24 
25  struct vertmesh : mesh
26  {
32 
35 
36  vertmesh() : verts(nullptr), tcverts(nullptr), bumpverts(nullptr), tris(nullptr)
37  {
38  }
39 
40  ~vertmesh() override
41  {
42  DELETEA(verts);
45  DELETEA(tris);
46  }
47 
48  void smoothnorms(float limit = 0, bool areaweight = true)
49  {
50  if(((vertmeshgroup *)group)->numframes == 1) mesh::smoothnorms(verts, numverts, tris, numtris, limit, areaweight);
51  else buildnorms(areaweight);
52  }
53 
54  void buildnorms(bool areaweight = true)
55  {
56  mesh::buildnorms(verts, numverts, tris, numtris, areaweight, ((vertmeshgroup *)group)->numframes);
57  }
58 
59  void calctangents(bool areaweight = true)
60  {
61  if(bumpverts) return;
62  bumpverts = new bumpvert[((vertmeshgroup *)group)->numframes*numverts];
63  mesh::calctangents(bumpverts, verts, tcverts, numverts, tris, numtris, areaweight, ((vertmeshgroup *)group)->numframes);
64  }
65 
66  void calcbb(vec &bbmin, vec &bbmax, const matrix4x3 &m) override
67  {
69  {
70  vec v = m.transform(verts[j].pos);
71  loopi(3)
72  {
73  bbmin[i] = min(bbmin[i], v[i]);
74  bbmax[i] = max(bbmax[i], v[i]);
75  }
76  }
77  }
78 
79  void genBIH(BIH::mesh &m) override
80  {
81  m.tris = (const BIH::tri *)tris;
82  m.numtris = numtris;
83  m.pos = (const uchar *)&verts->pos;
84  m.posstride = sizeof(vert);
85  m.tc = (const uchar *)&tcverts->tc;
86  m.tcstride = sizeof(tcvert);
87  }
88 
89  static inline void assignvert(vvertn &vv, int j, tcvert &tc, vert &v)
90  {
91  vv.pos = v.pos;
92  vv.norm = v.norm;
93  vv.tc = tc.tc;
94  }
95 
96  inline void assignvert(vvertbump &vv, int j, tcvert &tc, vert &v)
97  {
98  vv.pos = v.pos;
99  vv.tc = tc.tc;
100  vv.tangent = bumpverts[j].tangent;
101  }
102 
103  template<class T>
104  int genvbo(vector<ushort> &idxs, int offset, vector<T> &vverts, int *htdata, int htlen)
105  {
106  voffset = offset;
107  eoffset = idxs.length();
108  minvert = 0xFFFF;
109  loopi(numtris)
110  {
111  tri &t = tris[i];
112  loopj(3)
113  {
114  int index = t.vert[j];
115  tcvert &tc = tcverts[index];
116  vert &v = verts[index];
117  T vv;
118  assignvert(vv, index, tc, v);
119  int htidx = hthash(v.pos)&(htlen-1);
120  loopk(htlen)
121  {
122  int &vidx = htdata[(htidx+k)&(htlen-1)];
123  if(vidx < 0) { vidx = idxs.add(ushort(vverts.length())); vverts.add(vv); break; }
124  else if(!memcmp(&vverts[vidx], &vv, sizeof(vv))) { minvert = min(minvert, idxs.add(ushort(vidx))); break; }
125  }
126  }
127  }
129  maxvert = max(minvert, ushort(vverts.length()-1));
130  elen = idxs.length()-eoffset;
131  return vverts.length()-voffset;
132  }
133 
134  int genvbo(vector<ushort> &idxs, int offset)
135  {
136  voffset = offset;
137  eoffset = idxs.length();
138  loopi(numtris)
139  {
140  tri &t = tris[i];
141  loopj(3) idxs.add(voffset+t.vert[j]);
142  }
143  minvert = voffset;
144  maxvert = voffset + numverts-1;
145  elen = idxs.length()-eoffset;
146  return numverts;
147  }
148 
149  template<class T>
150  static inline void fillvert(T &vv, int j, tcvert &tc, vert &v)
151  {
152  vv.tc = tc.tc;
153  }
154 
155  template<class T>
156  void fillverts(T *vdata)
157  {
158  vdata += voffset;
159  loopi(numverts) fillvert(vdata[i], i, tcverts[i], verts[i]);
160  }
161 
162  void interpverts(const animstate &as, bool tangents, void * RESTRICT vdata, skin &s)
163  {
164  const vert * RESTRICT vert1 = &verts[as.cur.fr1 * numverts],
165  * RESTRICT vert2 = &verts[as.cur.fr2 * numverts],
166  * RESTRICT pvert1 = as.interp<1 ? &verts[as.prev.fr1 * numverts] : nullptr,
167  * RESTRICT pvert2 = as.interp<1 ? &verts[as.prev.fr2 * numverts] : nullptr;
168  #define ipvert(attrib) v.attrib.lerp(vert1[i].attrib, vert2[i].attrib, as.cur.t)
169  #define ipbvert(attrib, type) v.attrib.lerp(bvert1[i].attrib, bvert2[i].attrib, as.cur.t)
170  #define ipvertp(attrib) v.attrib.lerp(pvert1[i].attrib, pvert2[i].attrib, as.prev.t).lerp(vec().lerp(vert1[i].attrib, vert2[i].attrib, as.cur.t), as.interp)
171  #define ipbvertp(attrib, type) v.attrib.lerp(type().lerp(bpvert1[i].attrib, bpvert2[i].attrib, as.prev.t), type().lerp(bvert1[i].attrib, bvert2[i].attrib, as.cur.t), as.interp)
172  #define iploop(type, body) \
173  loopi(numverts) \
174  { \
175  type &v = ((type * RESTRICT)vdata)[i]; \
176  body; \
177  }
178  if(tangents)
179  {
180  const bumpvert * RESTRICT bvert1 = &bumpverts[as.cur.fr1 * numverts],
181  * RESTRICT bvert2 = &bumpverts[as.cur.fr2 * numverts],
182  * RESTRICT bpvert1 = as.interp<1 ? &bumpverts[as.prev.fr1 * numverts] : nullptr,
183  * RESTRICT bpvert2 = as.interp<1 ? &bumpverts[as.prev.fr2 * numverts] : nullptr;
184  if(as.interp<1) iploop(vvertbump, { ipvertp(pos); ipbvertp(tangent, vec4); })
185  else iploop(vvertbump, { ipvert(pos); ipbvert(tangent, vec4); })
186  }
187  else
188  {
189  if(as.interp<1) iploop(vvertn, { ipvertp(pos); ipvertp(norm); })
190  else iploop(vvertn, { ipvert(pos); ipvert(norm); })
191  }
192  #undef iploop
193  #undef ipvert
194  #undef ipbvert
195  #undef ipvertp
196  #undef ipbvertp
197  }
198 
199  void render(const animstate *as, skin &s, vbocacheentry &vc)
200  {
201  glDrawRangeElements_(GL_TRIANGLES, minvert, maxvert, elen, GL_UNSIGNED_SHORT, &((vertmeshgroup *)group)->edata[eoffset]);
202  glde++;
204  }
205  };
206 
207  struct tag
208  {
209  char *name;
211 
212  tag() : name(nullptr) {}
213  ~tag() { DELETEA(name); }
214  };
215 
217  {
220  int numtags;
221 
222  static const int MAXVBOCACHE = 16;
223  vbocacheentry vbocache[MAXVBOCACHE];
224 
227  bool vtangents;
228  int vlen, vertsize;
230 
231  vertmeshgroup() : numframes(0), tags(nullptr), numtags(0), edata(nullptr), ebuf(0), vtangents(false), vlen(0), vertsize(0), vdata(nullptr)
232  {
233  }
234 
235  ~vertmeshgroup() override
236  {
237  DELETEA(tags);
238  if(ebuf) glDeleteBuffers_(1, &ebuf);
239  loopi(MAXVBOCACHE)
240  {
241  if(vbocache[i].vbuf) glDeleteBuffers_(1, &vbocache[i].vbuf);
242  }
243  DELETEA(vdata);
244  }
245 
246  int findtag(const char *name) override
247  {
248  loopi(numtags) if(!strcmp(tags[i].name, name)) return i;
249  return -1;
250  }
251 
252  int totalframes() const override { return numframes; }
253 
254  void concattagtransform(part *p, int i, const matrix4x3 &m, matrix4x3 &n) override
255  {
256  n.mul(m, tags[numtags + i].transform);
258  }
259 
260  void calctagmatrix(part *p, int i, const animstate &as, matrix4 &matrix)
261  {
262  const matrix4x3 &tag1 = tags[as.cur.fr1*numtags + i].transform,
263  &tag2 = tags[as.cur.fr2*numtags + i].transform;
264  matrix4x3 tag;
265  tag.lerp(tag1, tag2, as.cur.t);
266  if(as.interp<1)
267  {
268  const matrix4x3 &tag1p = tags[as.prev.fr1*numtags + i].transform,
269  &tag2p = tags[as.prev.fr2*numtags + i].transform;
270  matrix4x3 tagp;
271  tagp.lerp(tag1p, tag2p, as.prev.t);
272  tag.lerp(tagp, tag, as.interp);
273  }
274  tag.d.add(p->translate).mul(p->model->scale);
275  matrix = matrix4(tag);
276  }
277 
278  void genvbo(bool tangents, vbocacheentry &vc)
279  {
280  if(!vc.vbuf) glGenBuffers_(1, &vc.vbuf);
281  if(ebuf) return;
282 
283  vector<ushort> idxs;
284 
285  if(tangents) loopv(meshes) ((vertmesh *)meshes[i])->calctangents();
286 
287  vtangents = tangents;
288  vertsize = tangents ? sizeof(vvertbump) : sizeof(vvertn);
289  vlen = 0;
290  if(numframes>1)
291  {
292  loopv(meshes) vlen += ((vertmesh *)meshes[i])->genvbo(idxs, vlen);
293  DELETEA(vdata);
294  vdata = new uchar[vlen*vertsize];
295  #define FILLVDATA(type) do { \
296  loopv(meshes) ((vertmesh *)meshes[i])->fillverts((type *)vdata); \
297  } while(0)
298  if(tangents) FILLVDATA(vvertbump);
299  else FILLVDATA(vvertn);
300  #undef FILLVDATA
301  }
302  else
303  {
304  gle::bindvbo(vc.vbuf);
305  #define GENVBO(type) do { \
306  vector<type> vverts; \
307  loopv(meshes) vlen += ((vertmesh *)meshes[i])->genvbo(idxs, vlen, vverts, htdata, htlen); \
308  glBufferData_(GL_ARRAY_BUFFER, vverts.length()*sizeof(type), vverts.getbuf(), GL_STATIC_DRAW); \
309  } while(0)
310  int numverts = 0, htlen = 128;
311  loopv(meshes) numverts += ((vertmesh *)meshes[i])->numverts;
312  while(htlen < numverts) htlen *= 2;
313  if(numverts*4 > htlen*3) htlen *= 2;
314  int *htdata = new int[htlen];
315  memset(htdata, -1, htlen*sizeof(int));
316  if(tangents) GENVBO(vvertbump);
317  else GENVBO(vvertn);
318  delete[] htdata;
319  #undef GENVBO
320  gle::clearvbo();
321  }
322 
323  glGenBuffers_(1, &ebuf);
325  glBufferData_(GL_ELEMENT_ARRAY_BUFFER, idxs.length()*sizeof(ushort), idxs.getbuf(), GL_STATIC_DRAW);
326  gle::clearebo();
327  }
328 
329  void bindvbo(const animstate *as, vbocacheentry &vc)
330  {
331  vvert *vverts = nullptr;
332  bindpos(ebuf, vc.vbuf, &vverts->pos, vertsize);
333  if(as->cur.anim&ANIM_NOSKIN)
334  {
335  if(enabletc) disabletc();
338  }
339  else
340  {
341  if(vtangents)
342  {
344  vvertbump *vvertbumps = nullptr;
345  bindtangents(&vvertbumps->tangent, vertsize);
346  }
347  else
348  {
350  vvertn *vvertns = nullptr;
351  bindnormals(&vvertns->norm, vertsize);
352  }
353 
354  bindtc(&vverts->tc, vertsize);
355  }
357  }
358 
359  void cleanup() override
360  {
361  loopi(MAXVBOCACHE)
362  {
363  vbocacheentry &c = vbocache[i];
364  if(c.vbuf) { glDeleteBuffers_(1, &c.vbuf); c.vbuf = 0; }
365  c.as.cur.fr1 = -1;
366  }
367  if(ebuf) { glDeleteBuffers_(1, &ebuf); ebuf = 0; }
368  }
369 
370  void preload(part *p) override
371  {
372  if(numframes > 1) return;
373  bool tangents = p->tangents();
374  if(tangents!=vtangents) cleanup();
375  if(!vbocache->vbuf) genvbo(tangents, *vbocache);
376  }
377 
378  void render(const animstate *as, float pitch, const vec &axis, const vec &forward, dynent *d, part *p) override
379  {
380  if(as->cur.anim&ANIM_NORENDER)
381  {
382  loopv(p->links) calctagmatrix(p, p->links[i].tag, *as, p->links[i].matrix);
383  return;
384  }
385 
386  bool tangents = p->tangents();
387  if(tangents!=vtangents) { cleanup(); disablevbo(); }
388  vbocacheentry *vc = nullptr;
389  if(numframes<=1) vc = vbocache;
390  else
391  {
392  loopi(MAXVBOCACHE)
393  {
394  vbocacheentry &c = vbocache[i];
395  if(!c.vbuf) continue;
396  if(c.as==*as) { vc = &c; break; }
397  }
398  if(!vc) loopi(MAXVBOCACHE) { vc = &vbocache[i]; if(!vc->vbuf || vc->millis < lastmillis) break; }
399  }
400  if(!vc->vbuf) genvbo(tangents, *vc);
401  if(numframes>1)
402  {
403  if(vc->as!=*as)
404  {
405  vc->as = *as;
406  vc->millis = lastmillis;
407  loopv(meshes)
408  {
409  vertmesh &m = *(vertmesh *)meshes[i];
410  m.interpverts(*as, tangents, vdata + m.voffset*vertsize, p->skins[i]);
411  }
412  gle::bindvbo(vc->vbuf);
413  glBufferData_(GL_ARRAY_BUFFER, vlen*vertsize, vdata, GL_STREAM_DRAW);
414  }
415  vc->millis = lastmillis;
416  }
417 
418  bindvbo(as, *vc);
419  loopv(meshes)
420  {
421  vertmesh *m = (vertmesh *)meshes[i];
422  p->skins[i].bind(m, as);
423  m->render(as, p->skins[i], *vc);
424  }
425 
426  loopv(p->links) calctagmatrix(p, p->links[i].tag, *as, p->links[i].matrix);
427  }
428  };
429 
430  vertmodel(const char *name) : animmodel(name)
431  {
432  }
433 };
434 
435 template<class MDL> struct vertloader : modelloader<MDL>
436 {
437 };
438 
439 template<class MDL> struct vertcommands : modelcommands<MDL, struct MDL::vertmesh>
440 {
441  typedef struct MDL::part part;
442  typedef struct MDL::skin skin;
443 
444  static void loadpart(char *model, float *smooth)
445  {
446  if(!MDL::loading) { Log.std->error("not loading an {0}", MDL::formatname()); return; }
447  defformatstring(filename, "%s/%s", MDL::dir, model);
448  part &mdl = MDL::loading->addpart();
449  if(mdl.index) mdl.pitchscale = mdl.pitchoffset = mdl.pitchmin = mdl.pitchmax = 0;
450  mdl.meshes = MDL::loading->sharemeshes(path(filename), double(*smooth > 0 ? cos(clamp(*smooth, 0.0f, 180.0f)*RAD) : 2));
451  if(!mdl.meshes) Log.std->error("could not load {0}", filename);
452  else mdl.initskins();
453  }
454 
455  static void setpitch(float *pitchscale, float *pitchoffset, float *pitchmin, float *pitchmax)
456  {
457  if(!MDL::loading || MDL::loading->parts.empty()) { Log.std->error("not loading an {0}", MDL::formatname()); return; }
458  part &mdl = *MDL::loading->parts.last();
459 
460  mdl.pitchscale = *pitchscale;
461  mdl.pitchoffset = *pitchoffset;
462  if(*pitchmin || *pitchmax)
463  {
464  mdl.pitchmin = *pitchmin;
465  mdl.pitchmax = *pitchmax;
466  }
467  else
468  {
469  mdl.pitchmin = -360*fabs(mdl.pitchscale) + mdl.pitchoffset;
470  mdl.pitchmax = 360*fabs(mdl.pitchscale) + mdl.pitchoffset;
471  }
472  }
473 
474  static void setanim(char *anim, int *frame, int *range, float *speed, int *priority)
475  {
476  if(!MDL::loading || MDL::loading->parts.empty()) { Log.std->error("not loading an {0}", MDL::formatname()); return; }
477  vector<int> anims;
478  findanims(anim, anims);
479  if(anims.empty()) Log.std->error("could not find animation {0}", anim);
480  else loopv(anims)
481  {
482  MDL::loading->parts.last()->setanim(0, anims[i], *frame, *range, *speed, *priority);
483  }
484  }
485 
487  {
488  if(MDL::multiparted()) this->modelcommand(loadpart, "load", "sf");
489  this->modelcommand(setpitch, "pitch", "ffff");
490  if(MDL::animated()) this->modelcommand(setanim, "anim", "siiff");
491  }
492 };
493 
int vlen
Definition: vertmodel.hpp:228
#define ipvertp(attrib)
vertmesh()
Definition: vertmodel.hpp:36
void render(const animstate *as, skin &s, vbocacheentry &vc)
Definition: vertmodel.hpp:199
Definition: geom.hpp:902
bool empty() const
is this vector empty?
Definition: cube_vector.hpp:141
#define RAD
Definition: cube_types.hpp:32
int millis
Definition: vertmodel.hpp:20
struct MDL::part part
Definition: vertmodel.hpp:441
GLuint ebuf
Definition: explosion.cpp:36
char * name
Definition: vertmodel.hpp:209
const T & max(const inexor::rpc::SharedVar< T > &a, const T &b)
Definition: SharedVar.hpp:224
Definition: vertmodel.hpp:25
static void setanim(char *anim, int *frame, int *range, float *speed, int *priority)
Definition: vertmodel.hpp:474
static void clearvbo()
Definition: glemu.hpp:103
Definition: bih.hpp:39
Definition: animmodel.hpp:465
Definition: geom.hpp:1897
void concattagtransform(part *p, int i, const matrix4x3 &m, matrix4x3 &n) override
Definition: vertmodel.hpp:254
animpos cur
Definition: animmodel.hpp:58
void bindvbo(const animstate *as, vbocacheentry &vc)
Definition: vertmodel.hpp:329
bumpvert * bumpverts
Definition: vertmodel.hpp:29
static Logger std
Logger for everything not fitting elsewhere.
Definition: Logging.hpp:89
vec norm
Definition: vertmodel.hpp:8
const tri * tris
Definition: bih.hpp:65
void smoothnorms(V *verts, int numverts, T *tris, int numtris, float limit, bool areaweight)
Definition: animmodel.hpp:312
tag()
Definition: vertmodel.hpp:212
void smooth()
Definition: octaedit.cpp:1942
#define iploop(type, body)
static void disablebones()
Definition: animmodel.hpp:1324
int genvbo(vector< ushort > &idxs, int offset, vector< T > &vverts, int *htdata, int htlen)
Definition: vertmodel.hpp:104
Definition: model.hpp:40
vec & mul(const vec &o)
scalar multiplication
Definition: geom.hpp:168
Definition: animmodel.hpp:104
int tcstride
Definition: bih.hpp:69
~vertmesh() override
Definition: vertmodel.hpp:40
vector< skin > skins
Definition: animmodel.hpp:615
void genvbo(bool tangents, vbocacheentry &vc)
Definition: vertmodel.hpp:278
static void loadpart(char *model, float *smooth)
Definition: vertmodel.hpp:444
void findanims(const char *pattern, vector< int > &anims)
Definition: rendermodel.cpp:1066
vec pos
Definition: vertmodel.hpp:8
void lerp(const matrix4x3 &to, float t)
Definition: geom.hpp:968
static void bindvbo(GLuint vbo)
Definition: glemu.hpp:102
void cleanup() override
Definition: animmodel.hpp:1129
T * getbuf()
get the whole vector
Definition: cube_vector.hpp:169
2-dimensional float vectors
Definition: geom.hpp:38
vec pos
Definition: vertmodel.hpp:9
tri * tris
Definition: vertmodel.hpp:30
int posstride
Definition: bih.hpp:69
PFNGLDELETEBUFFERSPROC glDeleteBuffers_
Definition: rendergl.cpp:128
int genvbo(vector< ushort > &idxs, int offset)
Definition: vertmodel.hpp:134
float scale
Definition: model.hpp:45
int numtris
Definition: vertmodel.hpp:31
meshgroup * group
Definition: animmodel.hpp:279
#define ipbvertp(attrib, type)
Definition: animmodel.hpp:55
static void clearebo()
Definition: glemu.hpp:101
char * name
Definition: animmodel.hpp:280
Definition: vertmodel.hpp:207
int xtravertsva
Definition: rendergl.cpp:1943
vec transform(const vec &o) const
Definition: geom.hpp:1100
ICOMMAND * f(float *a, float *b), floatret(*a **b)
4-dimensional float vector all methods stay basicly the same but with an extra dimension ...
Definition: geom.hpp:343
animstate as
Definition: vertmodel.hpp:19
#define FILLVDATA(type)
Definition: vertmodel.hpp:9
static void disablenormals()
Definition: animmodel.hpp:1343
typedef GLuint(APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program
int totalframes() const override
Definition: vertmodel.hpp:252
unsigned short ushort
Definition: cube_types.hpp:8
Definition: animmodel.hpp:1394
void buildnorms(V *verts, int numverts, T *tris, int numtris, bool areaweight)
Definition: animmodel.hpp:360
int findtag(const char *name) override
Definition: vertmodel.hpp:246
int fr2
Definition: animmodel.hpp:14
int numtags
Definition: vertmodel.hpp:220
vertmeshgroup()
Definition: vertmodel.hpp:231
else loopi(numargs)
Definition: command.cpp:3019
PFNGLGENBUFFERSPROC glGenBuffers_
Definition: rendergl.cpp:122
animpos prev
Definition: animmodel.hpp:58
int eoffset
Definition: vertmodel.hpp:33
#define GENVBO(type)
void smoothnorms(float limit=0, bool areaweight=true)
Definition: vertmodel.hpp:48
static bool enablenormals
Definition: animmodel.hpp:1305
void mul(float k)
Definition: geom.hpp:925
GLuint index
Definition: glexts.hpp:412
int numverts
Definition: vertmodel.hpp:31
struct MDL::skin skin
Definition: vertmodel.hpp:442
int voffset
Definition: vertmodel.hpp:33
#define RESTRICT
Definition: cube_tools.hpp:18
vec d
Definition: geom.hpp:904
int lastmillis
Definition: legacy_time.cpp:14
void translate(const vec &p)
Definition: geom.hpp:949
vec2 tc
Definition: vertmodel.hpp:12
int anim
Definition: animmodel.hpp:14
T & add(const T &x)
Add new index to vector.
Definition: cube_vector.hpp:73
int glde
Definition: octarender.cpp:1235
vector with 3 floats and some useful methods.
Definition: geom.hpp:110
#define DELETEA(p)
Delete Array, Wrapper around delete[], sets pointer to NULL afterwards(!).
Definition: cube_tools.hpp:31
#define ANIM_NOSKIN
Definition: ents.hpp:219
void buildnorms(bool areaweight=true)
Definition: vertmodel.hpp:54
vertcommands()
Definition: vertmodel.hpp:486
#define glDrawRangeElements_
Definition: glexts.hpp:27
static void disablevbo()
Definition: animmodel.hpp:1349
void fillverts(T *vdata)
Definition: vertmodel.hpp:156
void preload(part *p) override
Definition: vertmodel.hpp:370
Definition: vertmodel.hpp:216
const T & min(const inexor::rpc::SharedVar< T > &a, const T &b)
Definition: SharedVar.hpp:210
inexor::util::log_manager Log
Definition: Logging.cpp:241
Definition: geom.hpp:1572
static bool enablebones
Definition: animmodel.hpp:1305
#define ipvert(attrib)
static void fillvert(T &vv, int j, tcvert &tc, vert &v)
Definition: vertmodel.hpp:150
ushort * edata
Definition: vertmodel.hpp:225
PFNGLBUFFERDATAPROC glBufferData_
Definition: rendergl.cpp:126
GLuint ebuf
Definition: vertmodel.hpp:226
char * path(char *s)
Modifies the input string to only contain slashes in the direction the platform allows.
Definition: stream.cpp:63
static bool enabletc
Definition: animmodel.hpp:1305
bool tangents()
Definition: animmodel.hpp:713
const uchar * pos
Definition: bih.hpp:68
vec translate
Definition: animmodel.hpp:619
int vverts
Definition: octarender.cpp:1235
vert * verts
Definition: vertmodel.hpp:27
void calctagmatrix(part *p, int i, const animstate &as, matrix4 &matrix)
Definition: vertmodel.hpp:260
static void disabletc()
Definition: animmodel.hpp:1337
int length() const
return size of used memory
Definition: cube_vector.hpp:146
int numframes
Definition: vertmodel.hpp:218
void assignvert(vvertbump &vv, int j, tcvert &tc, vert &v)
Definition: vertmodel.hpp:96
tcvert * tcverts
Definition: vertmodel.hpp:28
int d
Definition: octaedit.cpp:1749
float t
Definition: animmodel.hpp:15
void t(T x, const char *cmp)
Definition: utilTest.cpp:52
void calctangents(B *bumpverts, V *verts, TC *tcverts, int numverts, T *tris, int numtris, bool areaweight)
Definition: animmodel.hpp:405
Definition: ents.hpp:258
squat tangent
Definition: vertmodel.hpp:11
#define dir(name, v, d, s, os)
Definition: physics.cpp:2014
#define loopk(m)
Definition: cube_loops.hpp:10
Definition: vertmodel.hpp:435
Definition: vertmodel.hpp:13
vector< part * > parts
Definition: animmodel.hpp:1118
unsigned char uchar
Basic type definitions.
Definition: cube_types.hpp:7
void cleanup() override
Definition: vertmodel.hpp:359
void calctangents(bool areaweight=true)
Definition: vertmodel.hpp:59
tag * tags
Definition: vertmodel.hpp:219
ushort maxvert
Definition: vertmodel.hpp:34
static void assignvert(vvertn &vv, int j, tcvert &tc, vert &v)
Definition: vertmodel.hpp:89
vertmodel(const char *name)
Definition: vertmodel.hpp:430
vector< linkedpart > links
Definition: animmodel.hpp:614
GLintptr offset
Definition: glexts.hpp:354
GLuint vbuf
Definition: vertmodel.hpp:18
Definition: vertmodel.hpp:6
#define ANIM_NORENDER
Definition: ents.hpp:223
Definition: vertmodel.hpp:10
Definition: animmodel.hpp:1407
bool vtangents
Definition: vertmodel.hpp:227
int fr1
Definition: animmodel.hpp:14
static bool enabletangents
Definition: animmodel.hpp:1305
int numtris
Definition: bih.hpp:67
ushort minvert
Definition: vertmodel.hpp:34
vec & add(const vec &o)
scalar sum
Definition: geom.hpp:174
static void disabletangents()
Definition: animmodel.hpp:1331
vec2 tc
Definition: vertmodel.hpp:9
Definition: animmodel.hpp:609
vec norm
Definition: vertmodel.hpp:10
float interp
Definition: animmodel.hpp:59
int elen
Definition: vertmodel.hpp:33
#define loopj(m)
Definition: cube_loops.hpp:9
matrix4x3 transform
Definition: vertmodel.hpp:210
void interpverts(const animstate &as, bool tangents, void *RESTRICT vdata, skin &s)
Definition: vertmodel.hpp:162
static void tangent(float x, float y, float z, float w=1.0f)
Definition: glemu.hpp:77
Definition: vertmodel.hpp:14
Definition: vertmodel.hpp:439
Definition: vertmodel.hpp:8
vec4 tangent
Definition: vertmodel.hpp:13
Definition: vertmodel.hpp:16
static void setpitch(float *pitchscale, float *pitchoffset, float *pitchmin, float *pitchmax)
Definition: vertmodel.hpp:455
Definition: bih.hpp:58
Definition: vertmodel.hpp:11
vacollect vc
mathmatics for vectors, matrices, quaterions and more
static void bindebo(GLuint ebo)
Definition: glemu.hpp:100
~vertmeshgroup() override
Definition: vertmodel.hpp:235
#define defformatstring(d,...)
Definition: cube_formatting.hpp:62
#define ipbvert(attrib, type)
void render(const animstate *as, float pitch, const vec &axis, const vec &forward, dynent *d, part *p) override
Definition: vertmodel.hpp:378
vec transformnormal(const vec &o) const
Definition: geom.hpp:1102
void calcbb(vec &bbmin, vec &bbmax, const matrix4x3 &m) override
Definition: vertmodel.hpp:66
#define loopv(v)
Definition: cube_loops.hpp:21
~tag()
Definition: vertmodel.hpp:213
ushort vert[3]
Definition: vertmodel.hpp:14
Definition: animmodel.hpp:3
Definition: random.cpp:21
Definition: animmodel.hpp:277
void genBIH(BIH::mesh &m) override
Definition: vertmodel.hpp:79
const uchar * tc
Definition: bih.hpp:68
animmodel * model
Definition: animmodel.hpp:611
GLuint vbuf
Definition: explosion.cpp:36
uchar * vdata
Definition: vertmodel.hpp:229
vbocacheentry()
Definition: vertmodel.hpp:22
static uint hthash(const fileskey &k)
Definition: console.cpp:698
Definition: vertmodel.hpp:12