Fix skinning bugs, optimize, re-enable a lighting optimization

This commit is contained in:
Henrik Rydgard 2012-11-11 19:00:44 +01:00
parent dfabd74020
commit 07e753da9f
2 changed files with 17 additions and 9 deletions

View File

@ -122,8 +122,8 @@ void Light(float colorOut[4], const float colorIn[4], Vec3 pos, Vec3 normal, flo
for (int l = 0; l < 4; l++)
{
// can we skip this light?
//if ((gstate.lightEnable[l] & 1) == 0) // && !doShadeMapping)
// continue;
if ((gstate.lightEnable[l] & 1) == 0 && !doShadeMapping)
continue;
GELightComputation comp = (GELightComputation)(gstate.ltype[l]&3);
GELightType type = (GELightType)((gstate.ltype[l]>>8)&3);
@ -286,14 +286,16 @@ void TransformAndDrawPrim(void *verts, void *inds, int prim, int vertexCount, Li
// Skinning
Vec3 psum(0,0,0);
Vec3 nsum(0,0,0);
int nweights = (gstate.vertType & GE_VTYPE_WEIGHT_MASK) >> GE_VTYPE_WEIGHT_SHIFT;
for (int i = 0; i < nweights; i++)
int nweights = (gstate.vertType & GE_VTYPE_WEIGHTCOUNT_MASK) >> GE_VTYPE_WEIGHTCOUNT_SHIFT;
for (int i = 0; i < 8; i++)
{
Vec3ByMatrix43(out, decoded[index].pos, gstate.boneMatrix+i*12);
Norm3ByMatrix43(norm, decoded[index].normal, gstate.boneMatrix+i*12);
Vec3 tpos(out), tnorm(norm);
psum += tpos*decoded[index].weights[i];
nsum += tnorm*decoded[index].weights[i];
if (decoded[index].weights[i] != 0.0f) {
Vec3ByMatrix43(out, decoded[index].pos, gstate.boneMatrix+i*12);
Norm3ByMatrix43(norm, decoded[index].normal, gstate.boneMatrix+i*12);
Vec3 tpos(out), tnorm(norm);
psum += tpos*decoded[index].weights[i];
nsum += tnorm*decoded[index].weights[i];
}
}
nsum.Normalize();

View File

@ -289,6 +289,12 @@ enum GEBufferFormat
#define GE_VTYPE_WEIGHT_MASK (3<<9)
#define GE_VTYPE_WEIGHT_SHIFT 9
#define GE_VTYPE_WEIGHTCOUNT_MASK (7<<14)
#define GE_VTYPE_WEIGHTCOUNT_SHIFT 14
#define GE_VTYPE_MORPHCOUNT_MASK (7<<18)
#define GE_VTYPE_MORPHCOUNT_SHIFT 18
#define GE_VTYPE_IDX_NONE (0<<11)
#define GE_VTYPE_IDX_8BIT (1<<11)
#define GE_VTYPE_IDX_16BIT (2<<11)