Fix shadow in Neverputt
authorparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Wed, 25 May 2011 16:46:27 +0000 (16:46 +0000)
committerparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Wed, 25 May 2011 16:46:27 +0000 (16:46 +0000)
git-svn-id: https://s.snth.net/svn/neverball/branches/gles@3581 78b8d119-cf0a-0410-b17c-f493084dd1d7

ball/game_draw.c
ball/game_draw.h
putt/game.c
share/solid_draw.c
share/solid_draw.h

index da0e2e7..23f63da 100644 (file)
@@ -320,13 +320,13 @@ static void game_clip_ball(const struct game_draw *gd, int d, const float *p)
 }
 
 static void game_draw_fore(struct s_rend *rend,
-                           const struct game_draw *gd,
+                           struct game_draw *gd,
                            int pose, const float *M,
                            int d, float t)
 {
     const float *ball_p = gd->vary.uv[0].p;
 
-    const struct s_draw *draw = &gd->draw;
+    struct s_draw *draw = &gd->draw;
 
     glPushMatrix();
     {
@@ -395,7 +395,7 @@ static void game_draw_fore(struct s_rend *rend,
 
 /*---------------------------------------------------------------------------*/
 
-void game_draw(const struct game_draw *gd, int pose, float t)
+void game_draw(struct game_draw *gd, int pose, float t)
 {
     float fov = (float) config_get_d(CONFIG_VIEW_FOV);
 
@@ -406,6 +406,8 @@ void game_draw(const struct game_draw *gd, int pose, float t)
         const struct game_view *view = &gd->view;
         struct s_rend rend;
 
+        gd->draw.shadow = 0;
+
         sol_draw_enable(&rend);
 
         video_push_persp(fov, 0.1f, FAR_DIST);
index f2d1744..2559590 100644 (file)
@@ -32,7 +32,7 @@ struct game_draw
 /* FIXME: this is just for POSE_* constants. */
 #include "game_client.h"
 
-void game_draw(const struct game_draw *, int, float);
+void game_draw(struct game_draw *, int, float);
 
 /*---------------------------------------------------------------------------*/
 
index 4092376..e8f71d4 100644 (file)
@@ -275,11 +275,13 @@ void game_draw(int pose, float t)
 {
     const float light_p[4] = { 8.f, 32.f, 8.f, 0.f };
 
-    const struct s_draw *fp = &file.draw;
+    struct s_draw *fp = &file.draw;
     struct s_rend rend = { NULL };
 
     float fov = FOV;
 
+    fp->shadow = ball;
+
     sol_draw_enable(&rend);
 
     if (jump_b) fov *= 2.0f * fabsf(jump_dt - 0.5f);
index bc36334..38af14d 100644 (file)
@@ -56,7 +56,7 @@ static const int pass_in[] = {
 /*---------------------------------------------------------------------------*/
 
 static void sol_transform(const struct s_vary *vary,
-                          const struct v_body *bp)
+                          const struct v_body *bp, int ui)
 {
     float a;
     float e[4];
@@ -75,12 +75,14 @@ static void sol_transform(const struct s_vary *vary,
 
     /* Apply the shadow transform to the texture matrix. */
 
-    if (vary->uc && vary->uv->r > 0.0)
+    if (ui >= 0 && ui < vary->uc && vary->uv[ui].r > 0.0f)
     {
+        struct v_ball *up = vary->uv + ui;
+
         glActiveTexture_(GL_TEXTURE1);
         glMatrixMode(GL_TEXTURE);
         {
-            float k = 0.25f / vary->uv->r;
+            float k = 0.25f / up->r;
 
             glLoadIdentity();
 
@@ -98,9 +100,7 @@ static void sol_transform(const struct s_vary *vary,
 
             /* Move the shadow texture under the ball. */
 
-            glTranslatef(-vary->uv->p[0],
-                         -vary->uv->p[1],
-                         -vary->uv->p[2]);
+            glTranslatef(-up->p[0], -up->p[1], -up->p[2]);
 
             /* Apply the body position and rotation. */
 
@@ -741,7 +741,7 @@ static void sol_draw_all(const struct s_draw *draw, struct s_rend *rend, int p)
         {
             glPushMatrix();
             {
-                sol_transform(draw->vary, draw->vary->bv + bi);
+                sol_transform(draw->vary, draw->vary->bv + bi, draw->shadow);
                 sol_draw_body(draw->bv + bi, rend, p);
             }
             glPopMatrix();
index c7833fa..ecc62b8 100644 (file)
@@ -86,6 +86,7 @@ struct s_draw
     GLuint bill;
 
     int reflective;
+    int shadow;
 };
 
 /*---------------------------------------------------------------------------*/