~ubuntu-branches/ubuntu/wily/box2d/wily

« back to all changes in this revision

Viewing changes to Box2D/Testbed/Tests/RayCast.h

  • Committer: Package Import Robot
  • Author(s): Markus Koschany
  • Date: 2014-05-30 18:42:02 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20140530184202-hosw11agojg02ac3
Tags: 2.3.1+ds-1
* Imported Upstream version 2.3.1+ds.
* Fix debian/watch to determine new releases by parsing
  the SVN tags of upstream's version control system.
* Update get-orig-source target for new release.
* dh_strip override: Replace $VER variable with 2.3.0 string.
* debian/copyright: Add new Public Domain and Apache 2.0 license.
* libbox2d-dev.install:
  - Install *.cmake files in /usr/lib/$(DEB_HOST_MULTIARCH)/cmake/Box2D.

Show diffs side-by-side

added added

removed removed

Lines of Context:
302
302
                }
303
303
        }
304
304
 
305
 
        void Keyboard(unsigned char key)
 
305
        void Keyboard(int key)
306
306
        {
307
307
                switch (key)
308
308
                {
309
 
                case '1':
310
 
                case '2':
311
 
                case '3':
312
 
                case '4':
313
 
                case '5':
314
 
                case '6':
315
 
                        Create(key - '1');
 
309
                case GLFW_KEY_1:
 
310
                case GLFW_KEY_2:
 
311
                case GLFW_KEY_3:
 
312
                case GLFW_KEY_4:
 
313
                case GLFW_KEY_5:
 
314
                case GLFW_KEY_6:
 
315
                        Create(key - GLFW_KEY_1);
316
316
                        break;
317
317
 
318
 
                case 'd':
 
318
                case GLFW_KEY_D:
319
319
                        DestroyBody();
320
320
                        break;
321
321
 
322
 
                case 'm':
 
322
                case GLFW_KEY_M:
323
323
                        if (m_mode == e_closest)
324
324
                        {
325
325
                                m_mode = e_any;
340
340
                bool advanceRay = settings->pause == 0 || settings->singleStep;
341
341
 
342
342
                Test::Step(settings);
343
 
                m_debugDraw.DrawString(5, m_textLine, "Press 1-6 to drop stuff, m to change the mode");
 
343
                g_debugDraw.DrawString(5, m_textLine, "Press 1-6 to drop stuff, m to change the mode");
344
344
                m_textLine += DRAW_STRING_NEW_LINE;
345
345
                switch (m_mode)
346
346
                {
347
347
                case e_closest:
348
 
                        m_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: closest - find closest fixture along the ray");
 
348
                        g_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: closest - find closest fixture along the ray");
349
349
                        break;
350
350
                
351
351
                case e_any:
352
 
                        m_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: any - check for obstruction");
 
352
                        g_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: any - check for obstruction");
353
353
                        break;
354
354
 
355
355
                case e_multiple:
356
 
                        m_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: multiple - gather multiple fixtures");
 
356
                        g_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: multiple - gather multiple fixtures");
357
357
                        break;
358
358
                }
359
359
 
371
371
 
372
372
                        if (callback.m_hit)
373
373
                        {
374
 
                                m_debugDraw.DrawPoint(callback.m_point, 5.0f, b2Color(0.4f, 0.9f, 0.4f));
375
 
                                m_debugDraw.DrawSegment(point1, callback.m_point, b2Color(0.8f, 0.8f, 0.8f));
 
374
                                g_debugDraw.DrawPoint(callback.m_point, 5.0f, b2Color(0.4f, 0.9f, 0.4f));
 
375
                                g_debugDraw.DrawSegment(point1, callback.m_point, b2Color(0.8f, 0.8f, 0.8f));
376
376
                                b2Vec2 head = callback.m_point + 0.5f * callback.m_normal;
377
 
                                m_debugDraw.DrawSegment(callback.m_point, head, b2Color(0.9f, 0.9f, 0.4f));
 
377
                                g_debugDraw.DrawSegment(callback.m_point, head, b2Color(0.9f, 0.9f, 0.4f));
378
378
                        }
379
379
                        else
380
380
                        {
381
 
                                m_debugDraw.DrawSegment(point1, point2, b2Color(0.8f, 0.8f, 0.8f));
 
381
                                g_debugDraw.DrawSegment(point1, point2, b2Color(0.8f, 0.8f, 0.8f));
382
382
                        }
383
383
                }
384
384
                else if (m_mode == e_any)
388
388
 
389
389
                        if (callback.m_hit)
390
390
                        {
391
 
                                m_debugDraw.DrawPoint(callback.m_point, 5.0f, b2Color(0.4f, 0.9f, 0.4f));
392
 
                                m_debugDraw.DrawSegment(point1, callback.m_point, b2Color(0.8f, 0.8f, 0.8f));
 
391
                                g_debugDraw.DrawPoint(callback.m_point, 5.0f, b2Color(0.4f, 0.9f, 0.4f));
 
392
                                g_debugDraw.DrawSegment(point1, callback.m_point, b2Color(0.8f, 0.8f, 0.8f));
393
393
                                b2Vec2 head = callback.m_point + 0.5f * callback.m_normal;
394
 
                                m_debugDraw.DrawSegment(callback.m_point, head, b2Color(0.9f, 0.9f, 0.4f));
 
394
                                g_debugDraw.DrawSegment(callback.m_point, head, b2Color(0.9f, 0.9f, 0.4f));
395
395
                        }
396
396
                        else
397
397
                        {
398
 
                                m_debugDraw.DrawSegment(point1, point2, b2Color(0.8f, 0.8f, 0.8f));
 
398
                                g_debugDraw.DrawSegment(point1, point2, b2Color(0.8f, 0.8f, 0.8f));
399
399
                        }
400
400
                }
401
401
                else if (m_mode == e_multiple)
402
402
                {
403
403
                        RayCastMultipleCallback callback;
404
404
                        m_world->RayCast(&callback, point1, point2);
405
 
                        m_debugDraw.DrawSegment(point1, point2, b2Color(0.8f, 0.8f, 0.8f));
 
405
                        g_debugDraw.DrawSegment(point1, point2, b2Color(0.8f, 0.8f, 0.8f));
406
406
 
407
407
                        for (int32 i = 0; i < callback.m_count; ++i)
408
408
                        {
409
409
                                b2Vec2 p = callback.m_points[i];
410
410
                                b2Vec2 n = callback.m_normals[i];
411
 
                                m_debugDraw.DrawPoint(p, 5.0f, b2Color(0.4f, 0.9f, 0.4f));
412
 
                                m_debugDraw.DrawSegment(point1, p, b2Color(0.8f, 0.8f, 0.8f));
 
411
                                g_debugDraw.DrawPoint(p, 5.0f, b2Color(0.4f, 0.9f, 0.4f));
 
412
                                g_debugDraw.DrawSegment(point1, p, b2Color(0.8f, 0.8f, 0.8f));
413
413
                                b2Vec2 head = p + 0.5f * n;
414
 
                                m_debugDraw.DrawSegment(p, head, b2Color(0.9f, 0.9f, 0.4f));
 
414
                                g_debugDraw.DrawSegment(p, head, b2Color(0.9f, 0.9f, 0.4f));
415
415
                        }
416
416
                }
417
417
 
455
455
                                vs[i] = b2Mul(xf, shape.m_vertices[i]);
456
456
                        }
457
457
 
458
 
                        m_debugDraw.DrawPolygon(vs, 4, color);
459
 
                        m_debugDraw.DrawSegment(input.p1, input.p2, color);
 
458
                        g_debugDraw.DrawPolygon(vs, 4, color);
 
459
                        g_debugDraw.DrawSegment(input.p1, input.p2, color);
460
460
                }
461
461
#endif
462
462
        }