Populating missing attribs with default values.
This commit is contained in:
+29
-10
@@ -201,16 +201,19 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance)
|
|||||||
a++;
|
a++;
|
||||||
}
|
}
|
||||||
stride += 4;
|
stride += 4;
|
||||||
|
|
||||||
// Texture coordinates
|
if (geo->numTexCoordSets <= 0) stride += 8;
|
||||||
for(int32 n = 0; n < geo->numTexCoordSets; n++){
|
else {
|
||||||
a->index = ATTRIB_TEXCOORDS0+n;
|
// Texture coordinates
|
||||||
a->size = 2;
|
for(int32 n = 0; n < geo->numTexCoordSets; n++){
|
||||||
a->type = GL_FLOAT;
|
a->index = ATTRIB_TEXCOORDS0+n;
|
||||||
a->normalized = GL_FALSE;
|
a->size = 2;
|
||||||
a->offset = stride;
|
a->type = GL_FLOAT;
|
||||||
stride += 8;
|
a->normalized = GL_FALSE;
|
||||||
a++;
|
a->offset = stride;
|
||||||
|
stride += 8;
|
||||||
|
a++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header->numAttribs = a - tmpAttribs;
|
header->numAttribs = a - tmpAttribs;
|
||||||
@@ -252,6 +255,13 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance)
|
|||||||
instV3d(VERT_FLOAT3, verts + a->offset,
|
instV3d(VERT_FLOAT3, verts + a->offset,
|
||||||
geo->morphTargets[0].normals,
|
geo->morphTargets[0].normals,
|
||||||
header->totalNumVertex, a->stride);
|
header->totalNumVertex, a->stride);
|
||||||
|
} else if (!hasNormals) {
|
||||||
|
int i = 0;
|
||||||
|
while (i < header->totalNumVertex) {
|
||||||
|
float *verts_f = (float*)&verts[12 + i * 36];
|
||||||
|
verts_f[0] = verts_f[1] = verts_f[2] = 0;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prelighting
|
// Prelighting
|
||||||
@@ -268,6 +278,15 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance)
|
|||||||
inst->numVertices, a->stride);
|
inst->numVertices, a->stride);
|
||||||
inst++;
|
inst++;
|
||||||
}
|
}
|
||||||
|
} else if (!isPrelit) {
|
||||||
|
int i = 0;
|
||||||
|
while (i < header->totalNumVertex) {
|
||||||
|
verts[24 + i * 36] = 0;
|
||||||
|
verts[25 + i * 36] = 0;
|
||||||
|
verts[26 + i * 36] = 0;
|
||||||
|
verts[27 + i * 36] = 255;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Texture coordinates
|
// Texture coordinates
|
||||||
|
|||||||
@@ -147,6 +147,13 @@ skinInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance)
|
|||||||
instV3d(VERT_FLOAT3, verts + a->offset,
|
instV3d(VERT_FLOAT3, verts + a->offset,
|
||||||
geo->morphTargets[0].normals,
|
geo->morphTargets[0].normals,
|
||||||
header->totalNumVertex, a->stride);
|
header->totalNumVertex, a->stride);
|
||||||
|
} else if (!hasNormals) {
|
||||||
|
int i = 0;
|
||||||
|
while (i < header->totalNumVertex) {
|
||||||
|
float *verts_f = (float*)&verts[12 + i * 56];
|
||||||
|
verts_f[0] = verts_f[1] = verts_f[2] = 0;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prelighting
|
// Prelighting
|
||||||
@@ -156,6 +163,15 @@ skinInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance)
|
|||||||
instColor(VERT_RGBA, verts + a->offset,
|
instColor(VERT_RGBA, verts + a->offset,
|
||||||
geo->colors,
|
geo->colors,
|
||||||
header->totalNumVertex, a->stride);
|
header->totalNumVertex, a->stride);
|
||||||
|
} else if (!isPrelit) {
|
||||||
|
int i = 0;
|
||||||
|
while (i < header->totalNumVertex) {
|
||||||
|
verts[24 + i * 56] = 0;
|
||||||
|
verts[25 + i * 56] = 0;
|
||||||
|
verts[26 + i * 56] = 0;
|
||||||
|
verts[27 + i * 56] = 255;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Texture coordinates
|
// Texture coordinates
|
||||||
|
|||||||
Reference in New Issue
Block a user