Fixed the zero-velocity test in the edge/vert collision detection. Was producing...
authorrlk <rlk@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Mon, 31 Dec 2007 18:33:11 +0000 (18:33 +0000)
committerrlk <rlk@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Mon, 31 Dec 2007 18:33:11 +0000 (18:33 +0000)
Fixed a few warnings.

git-svn-id: https://s.snth.net/svn/neverball/trunk@1347 78b8d119-cf0a-0410-b17c-f493084dd1d7

ball/main.c
putt/main.c
share/image.c
share/solid.c
share/solid_gl.c

index f9fb625..6eab0d7 100644 (file)
@@ -290,7 +290,9 @@ static void parse_args(int argc, char **argv)
 int main(int argc, char *argv[])
 {
     SDL_Joystick *joy = NULL;
+#ifndef __APPLE__
     SDL_Surface *icon;
+#endif
 
     int t1, t0;
 
index 40b015e..7852d99 100644 (file)
@@ -195,7 +195,9 @@ static int loop(void)
 int main(int argc, char *argv[])
 {
     int camera = 0;
+#ifndef __APPLE__
     SDL_Surface *icon;
+#endif
     SDL_Joystick *joy = NULL;
 
     srand((int) time(NULL));
index 84343aa..3293ec3 100644 (file)
@@ -114,13 +114,14 @@ static GLuint make_texture(const void *p, int w, int h, int b)
     int k = config_get_d(CONFIG_TEXTURES);
     int W = w;
     int H = h;
-    int max;
+
+    GLint max;
 
     void *q = NULL;
 
     glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);
 
-    while (w / k > max || h / k > max)
+    while (w / k > (int) max || h / k > (int) max)
         k *= 2;
 
     if (k > 1)
index d844ef2..fa0f397 100644 (file)
@@ -29,6 +29,7 @@
 #define SOL_VERSION 6
 
 #define LARGE 1.0e+5f
+#define SMALL 1.0e-3f
 
 /*---------------------------------------------------------------------------*/
 
@@ -696,11 +697,10 @@ static float v_sol(const float p[3], const float v[3], float r)
     float c = v_dot(p, p) - r * r;
     float d = b * b - 4.0f * a * c;
 
-    if (a == 0.0f) return LARGE;
-    if (d <  0.0f) return LARGE;
+    if (fabsf(a) < SMALL) return LARGE;
 
-    if (d == 0.0f)
-        return -b * 0.5f / a;
+    if      (d <  0.0f) return LARGE;
+    else if (d == 0.0f) return -b * 0.5f / a;
     else
     {
         float t0 = 0.5f * (-b - fsqrtf(d)) / a;
index a35abbe..d47af25 100644 (file)
@@ -71,10 +71,12 @@ static int sol_enum_body(const struct s_file *fp,
 
 /*---------------------------------------------------------------------------*/
 
-#define color_cmp(a, b) ((a)[0] == (b)[0] && \
-                         (a)[1] == (b)[1] && \
-                         (a)[2] == (b)[2] && \
-                         (a)[3] == (b)[3])
+#define tobyte(f) ((GLubyte) (f * 255.0f))
+
+#define color_cmp(a, b) (tobyte((a)[0]) == tobyte((b)[0]) && \
+                         tobyte((a)[1]) == tobyte((b)[1]) && \
+                         tobyte((a)[2]) == tobyte((b)[2]) && \
+                         tobyte((a)[3]) == tobyte((b)[3]))
 
 static struct s_mtrl default_mtrl =
 {
@@ -99,7 +101,7 @@ static const struct s_mtrl *sol_draw_mtrl(const struct s_file *fp,
         glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,  mp->s);
     if (!color_cmp(mp->e, mq->e))
         glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION,  mp->e);
-    if (mp->h[0] != mq->h[0])
+    if (tobyte(mp->h[0]) != tobyte(mq->h[0]))
         glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mp->h);
 
     /* Bind the texture. */
@@ -158,7 +160,7 @@ static const struct s_mtrl *sol_back_bill(const struct s_file *fp,
                                           const struct s_bill *rp,
                                           const struct s_mtrl *mp, float t)
 {
-    float T = rp->t ? (fmodf(t, rp->t) - rp->t / 2) : 0.0f;
+    float T = (rp->t > 0.0f) ? (fmodf(t, rp->t) - rp->t / 2) : 0.0f;
 
     float w = rp->w[0] + rp->w[1] * T + rp->w[2] * T * T;
     float h = rp->h[0] + rp->h[1] * T + rp->h[2] * T * T;