File indexing completed on 2024-05-19 14:56:23

0001 /*
0002 * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
0003 *
0004 * This software is provided 'as-is', without any express or implied
0005 * warranty.  In no event will the authors be held liable for any damages
0006 * arising from the use of this software.
0007 * Permission is granted to anyone to use this software for any purpose,
0008 * including commercial applications, and to alter it and redistribute it
0009 * freely, subject to the following restrictions:
0010 * 1. The origin of this software must not be misrepresented; you must not
0011 * claim that you wrote the original software. If you use this software
0012 * in a product, an acknowledgment in the product documentation would be
0013 * appreciated but is not required.
0014 * 2. Altered source versions must be plainly marked as such, and must not be
0015 * misrepresented as being the original software.
0016 * 3. This notice may not be removed or altered from any source distribution.
0017 */
0018 
0019 #ifndef B2_TIME_OF_IMPACT_H
0020 #define B2_TIME_OF_IMPACT_H
0021 
0022 #include <Box2D/Common/b2Math.h>
0023 #include <Box2D/Collision/b2Distance.h>
0024 
0025 /// Input parameters for b2TimeOfImpact
0026 struct b2TOIInput
0027 {
0028     b2DistanceProxy proxyA;
0029     b2DistanceProxy proxyB;
0030     b2Sweep sweepA;
0031     b2Sweep sweepB;
0032     float32 tMax;       // defines sweep interval [0, tMax]
0033 };
0034 
0035 // Output parameters for b2TimeOfImpact.
0036 struct b2TOIOutput
0037 {
0038     enum State
0039     {
0040         e_unknown,
0041         e_failed,
0042         e_overlapped,
0043         e_touching,
0044         e_separated
0045     };
0046 
0047     State state;
0048     float32 t;
0049 };
0050 
0051 /// Compute the upper bound on time before two shapes penetrate. Time is represented as
0052 /// a fraction between [0,tMax]. This uses a swept separating axis and may miss some intermediate,
0053 /// non-tunneling collision. If you change the time interval, you should call this function
0054 /// again.
0055 /// Note: use b2Distance to compute the contact point and normal at the time of impact.
0056 void b2TimeOfImpact(b2TOIOutput* output, const b2TOIInput* input);
0057 
0058 #endif