using proper types

This commit is contained in:
aap
2017-08-05 01:44:37 +02:00
parent 9a26a380a8
commit 4653f7e81e
14 changed files with 155 additions and 180 deletions

View File

@@ -400,14 +400,14 @@ uint32*
instanceNormal(uint32 *wp, Geometry *g, Mesh *m, uint32 idx, uint32 n)
{
uint16 j;
float *d = g->morphTargets[0].normals;
V3d *d = g->morphTargets[0].normals;
uint8 *p = (uint8*)wp;
if((g->flags & Geometry::NORMALS))
for(uint32 i = idx; i < idx+n; i++){
j = m->indices[i];
*p++ = d[j*3+0]*127.0f;
*p++ = d[j*3+1]*127.0f;
*p++ = d[j*3+2]*127.0f;
*p++ = d[j].x*127.0f;
*p++ = d[j].y*127.0f;
*p++ = d[j].z*127.0f;
}
else
for(uint32 i = idx; i < idx+n; i++){
@@ -872,57 +872,19 @@ ObjPipeline::ObjPipeline(uint32 platform)
this->impl.uninstance = objUninstance;
}
/*
int32
findVertex(Geometry *g, uint32 flags[], uint32 mask, Vertex *v)
{
float32 *verts = g->morphTargets[0].vertices;
float32 *tex = g->texCoords[0];
float32 *tex1 = g->texCoords[1];
float32 *norms = g->morphTargets[0].normals;
uint8 *cols = g->colors;
for(int32 i = 0; i < g->numVertices; i++){
if(mask & flags[i] & 0x1 &&
!(verts[0] == v->p[0] && verts[1] == v->p[1] && verts[2] == v->p[2]))
goto cont;
if(mask & flags[i] & 0x10 &&
!(norms[0] == v->n[0] && norms[1] == v->n[1] && norms[2] == v->n[2]))
goto cont;
if(mask & flags[i] & 0x100 &&
!(cols[0] == v->c[0] && cols[1] == v->c[1] && cols[2] == v->c[2] && cols[3] == v->c[3]))
goto cont;
if(mask & flags[i] & 0x1000 &&
!(tex[0] == v->t[0] && tex[1] == v->t[1]))
goto cont;
if(mask & flags[i] & 0x2000 &&
!(tex1[0] == v->t1[0] && tex1[1] == v->t1[1]))
goto cont;
return i;
cont:
verts += 3;
tex += 2;
tex1 += 2;
norms += 3;
cols += 4;
}
return -1;
}
*/
void
insertVertex(Geometry *geo, int32 i, uint32 mask, Vertex *v)
{
if(mask & 0x1)
memcpy(&geo->morphTargets[0].vertices[i*3], v->p, 12);
geo->morphTargets[0].vertices[i] = v->p;
if(mask & 0x10)
memcpy(&geo->morphTargets[0].normals[i*3], v->n, 12);
geo->morphTargets[0].normals[i] = v->n;
if(mask & 0x100)
memcpy(&geo->colors[i*4], v->c, 4);
geo->colors[i] = v->c;
if(mask & 0x1000)
memcpy(&geo->texCoords[0][i*2], v->t, 8);
geo->texCoords[0][i] = v->t;
if(mask & 0x2000)
memcpy(&geo->texCoords[1][i*2], v->t1, 8);
geo->texCoords[1][i] = v->t1;
}
void
@@ -983,9 +945,9 @@ genericUninstanceCB(MatPipeline *pipe, Geometry *geo, uint32 flags[], Mesh *mesh
memcpy(&v.p, xyz ? xyz : xyzw, 12);
if(mask & 0x10){
// TODO: figure out scaling :/
v.n[0] = normals[0]/128.0f;
v.n[1] = normals[1]/128.0f;
v.n[2] = normals[2]/128.0f;
v.n.x = normals[0]/128.0f;
v.n.y = normals[1]/128.0f;
v.n.z = normals[2]/128.0f;
}
if(mask & 0x100)
memcpy(&v.c, rgba, 4);

View File

@@ -202,28 +202,23 @@ findVertexSkin(Geometry *g, uint32 flags[], uint32 mask, Vertex *v)
inds = skin->indices;
}
float32 *verts = g->morphTargets[0].vertices;
float32 *tex = g->texCoords[0];
float32 *tex1 = g->texCoords[1];
float32 *norms = g->morphTargets[0].normals;
uint8 *cols = g->colors;
V3d *verts = g->morphTargets[0].vertices;
TexCoords *tex = g->texCoords[0];
TexCoords *tex1 = g->texCoords[1];
V3d *norms = g->morphTargets[0].normals;
RGBA *cols = g->colors;
for(int32 i = 0; i < g->numVertices; i++){
uint32 flag = flags ? flags[i] : ~0;
if(mask & flag & 0x1 &&
!(verts[0] == v->p[0] && verts[1] == v->p[1] && verts[2] == v->p[2]))
if(mask & flag & 0x1 && !equal(*verts, v->p))
goto cont;
if(mask & flag & 0x10 &&
!(norms[0] == v->n[0] && norms[1] == v->n[1] && norms[2] == v->n[2]))
if(mask & flag & 0x10 && !equal(*norms, v->n))
goto cont;
if(mask & flag & 0x100 &&
!(cols[0] == v->c[0] && cols[1] == v->c[1] && cols[2] == v->c[2] && cols[3] == v->c[3]))
if(mask & flag & 0x100 && !equal(*cols, v->c))
goto cont;
if(mask & flag & 0x1000 &&
!(tex[0] == v->t[0] && tex[1] == v->t[1]))
if(mask & flag & 0x1000 && !equal(*tex, v->t))
goto cont;
if(mask & flag & 0x2000 &&
!(tex1[0] == v->t1[0] && tex1[1] == v->t1[1]))
if(mask & flag & 0x2000 && !equal(*tex1, v->t1))
goto cont;
if(mask & flag & 0x10000 &&
!(wghts[0] == v->w[0] && wghts[1] == v->w[1] &&
@@ -233,10 +228,11 @@ findVertexSkin(Geometry *g, uint32 flags[], uint32 mask, Vertex *v)
goto cont;
return i;
cont:
verts += 3;
tex += 2;
norms += 3;
cols += 4;
verts++;
tex++;
tex1++;
norms++;
cols++;
wghts += 4;
inds += 4;
}

View File

@@ -121,11 +121,11 @@ public:
};
struct Vertex {
float32 p[3];
float32 t[2];
float32 t1[2];
uint8 c[4];
float32 n[3];
V3d p;
TexCoords t;
TexCoords t1;
RGBA c;
V3d n;
// skin
float32 w[4];
uint8 i[4];