Fix -Wshadow;

This commit is contained in:
bjorn 2020-01-23 11:18:04 -08:00
parent 08577ee91b
commit 8c429e89ac
6 changed files with 36 additions and 35 deletions

View File

@ -10,9 +10,9 @@ static uint32_t luax_checkanimation(lua_State* L, int index, Model* model) {
size_t length;
const char* name = lua_tolstring(L, index, &length);
ModelData* modelData = lovrModelGetModelData(model);
uint64_t index = map_get(&modelData->animationMap, hash64(name, length));
lovrAssert(index != MAP_NIL, "Model has no animation named '%s'", name);
return (uint32_t) index;
uint64_t animationIndex = map_get(&modelData->animationMap, hash64(name, length));
lovrAssert(animationIndex != MAP_NIL, "Model has no animation named '%s'", name);
return (uint32_t) animationIndex;
}
case LUA_TNUMBER: return lua_tointeger(L, index) - 1;
default: return luaL_typerror(L, index, "number or string");

View File

@ -62,11 +62,12 @@ int luax_checkuniform(lua_State* L, int index, const Uniform* uniform, void* des
switch (uniformType) {
case UNIFORM_FLOAT: *((float*) dest + i) = luax_optfloat(L, j, 0.f); break;
case UNIFORM_INT: *((int*) dest + i) = luaL_optinteger(L, j, 0); break;
case UNIFORM_SAMPLER:
case UNIFORM_SAMPLER: {
*((Texture**) dest + i) = luax_checktype(L, j, Texture);
TextureType type = lovrTextureGetType(*((Texture**) dest + i));
lovrAssert(type == uniform->textureType, "Attempt to send %s texture to %s sampler uniform", TextureTypes[type], TextureTypes[uniform->textureType]);
break;
}
case UNIFORM_IMAGE: {
Image* image = (Image*) dest + i;

View File

@ -1468,9 +1468,9 @@ int l_lovrMat4Set(lua_State* L) {
}
} else {
VectorType vectorType;
float* v = luax_tovector(L, 2, &vectorType);
float* n = luax_tovector(L, 2, &vectorType);
if (vectorType == V_MAT4) {
mat4_init(m, v);
mat4_init(m, n);
} else {
int index = 2;
mat4_identity(m);

View File

@ -885,8 +885,8 @@ static void lovrGpuBindShader(Shader* shader) {
for (size_t i = 0; i < shader->uniforms.length; i++) {
Uniform* uniform = &shader->uniforms.data[i];
if (uniform->type == UNIFORM_SAMPLER) {
for (int i = 0; i < uniform->count; i++) {
Texture* texture = uniform->value.textures[i];
for (int j = 0; j < uniform->count; j++) {
Texture* texture = uniform->value.textures[j];
if (texture && texture->incoherent && (texture->incoherent >> BARRIER_UNIFORM_TEXTURE) & 1) {
flags |= 1 << BARRIER_UNIFORM_TEXTURE;
if (flags & (1 << BARRIER_UNIFORM_IMAGE)) {
@ -895,8 +895,8 @@ static void lovrGpuBindShader(Shader* shader) {
}
}
} else if (uniform->type == UNIFORM_IMAGE) {
for (int i = 0; i < uniform->count; i++) {
Texture* texture = uniform->value.images[i].texture;
for (int j = 0; j < uniform->count; j++) {
Texture* texture = uniform->value.images[j].texture;
if (texture && texture->incoherent && (texture->incoherent >> BARRIER_UNIFORM_IMAGE) & 1) {
flags |= 1 << BARRIER_UNIFORM_IMAGE;
if (flags & (1 << BARRIER_UNIFORM_TEXTURE)) {
@ -951,8 +951,8 @@ static void lovrGpuBindShader(Shader* shader) {
case UNIFORM_IMAGE:
#ifndef LOVR_WEBGL
for (int i = 0; i < count; i++) {
Image* image = &uniform->value.images[i];
for (int j = 0; j < count; j++) {
Image* image = &uniform->value.images[j];
Texture* texture = image->texture;
lovrAssert(!texture || texture->type == uniform->textureType, "Uniform texture type mismatch for uniform '%s'", uniform->name);
@ -964,17 +964,17 @@ static void lovrGpuBindShader(Shader* shader) {
}
}
lovrGpuBindImage(image, uniform->baseSlot + i);
lovrGpuBindImage(image, uniform->baseSlot + j);
}
#endif
break;
case UNIFORM_SAMPLER:
for (int i = 0; i < count; i++) {
Texture* texture = uniform->value.textures[i];
for (int j = 0; j < count; j++) {
Texture* texture = uniform->value.textures[j];
lovrAssert(!texture || texture->type == uniform->textureType, "Uniform texture type mismatch for uniform '%s'", uniform->name);
lovrAssert(!texture || (uniform->shadow == (texture->compareMode != COMPARE_NONE)), "Uniform '%s' requires a Texture with%s a compare mode", uniform->name, uniform->shadow ? "" : "out");
lovrGpuBindTexture(texture, uniform->baseSlot + i);
lovrGpuBindTexture(texture, uniform->baseSlot + j);
}
break;
}
@ -2105,8 +2105,8 @@ static void lovrShaderSetupUniforms(Shader* shader) {
lovrAssert(uniform.value.data, "Out of memory");
// Use the value for ints to bind texture slots, but use the value for textures afterwards.
for (int i = 0; i < uniform.count; i++) {
uniform.value.ints[i] = uniform.baseSlot + i;
for (int j = 0; j < uniform.count; j++) {
uniform.value.ints[j] = uniform.baseSlot + j;
}
glUniform1iv(uniform.location, uniform.count, uniform.value.ints);
memset(uniform.value.data, 0, uniform.size);

View File

@ -165,10 +165,12 @@ static void desktop_update(float dt) {
float damping = MAX(1.f - 20.f * dt, 0);
int width, height;
double mx, my, aspect = 1;
double mx, my;
lovrPlatformGetWindowSize(&width, &height);
lovrPlatformGetMousePosition(&mx, &my);
double aspect = (width > 0 && height > 0) ? ((double) width / height) : 1.;
// Mouse move
if (lovrPlatformIsMouseDown(MOUSE_LEFT)) {
lovrPlatformSetMouseMode(MOUSE_MODE_GRABBED);
@ -178,7 +180,6 @@ static void desktop_update(float dt) {
state.prevCursorY = my;
}
float aspect = (float) width / height;
float dx = (float) (mx - state.prevCursorX) / ((float) width);
float dy = (float) (my - state.prevCursorY) / ((float) height * aspect);
state.angularVelocity[0] = dy / dt;
@ -218,17 +219,16 @@ static void desktop_update(float dt) {
double px = mx, py = my;
if (width > 0 && height > 0) {
// change coordinate system to -1.0 to 1.0
px = (px / width)*2 - 1.0;
py = (py / height)*2 - 1.0;
aspect = height/(double)width;
px = (px / width) * 2 - 1.0;
py = (py / height) * 2 - 1.0;
px += 0.2; // neutral position = pointing towards center-ish
px *= 0.6; // fudged range to juuust cover pointing at the whole scene, but not outside it
px += .2; // neutral position = pointing towards center-ish
px *= .6; // fudged range to juuust cover pointing at the whole scene, but not outside it
}
mat4_set(state.leftHandTransform, state.headTransform);
double xrange = M_PI*0.2;
double yrange = xrange * aspect;
double xrange = M_PI * .2;
double yrange = xrange / aspect;
mat4_translate(state.leftHandTransform, -.1f, -.1f, -0.10f);
mat4_rotate(state.leftHandTransform, -px * xrange, 0, 1, 0);
mat4_rotate(state.leftHandTransform, -py * yrange, 1, 0, 0);

View File

@ -157,22 +157,22 @@ int lovrWorldCollide(World* world, Shape* a, Shape* b, float friction, float res
}
dContact contacts[MAX_CONTACTS];
for (int i = 0; i < MAX_CONTACTS; i++) {
contacts[i].surface.mode = 0;
contacts[i].surface.mu = friction;
contacts[i].surface.bounce = restitution;
contacts[i].surface.mu = dInfinity;
for (int c = 0; c < MAX_CONTACTS; c++) {
contacts[c].surface.mode = 0;
contacts[c].surface.mu = friction;
contacts[c].surface.bounce = restitution;
contacts[c].surface.mu = dInfinity;
if (restitution > 0) {
contacts[i].surface.mode |= dContactBounce;
contacts[c].surface.mode |= dContactBounce;
}
}
int contactCount = dCollide(a->id, b->id, MAX_CONTACTS, &contacts[0].geom, sizeof(dContact));
if (!a->sensor && !b->sensor) {
for (int i = 0; i < contactCount; i++) {
dJointID joint = dJointCreateContact(world->id, world->contactGroup, &contacts[i]);
for (int c = 0; c < contactCount; c++) {
dJointID joint = dJointCreateContact(world->id, world->contactGroup, &contacts[c]);
dJointAttach(joint, colliderA->body, colliderB->body);
}
}