OLD | NEW |
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2015, Daniel Murphy, Google | 2 * Copyright (c) 2015, Daniel Murphy, Google |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without modificati
on, | 5 * Redistribution and use in source and binary forms, with or without modificati
on, |
6 * are permitted provided that the following conditions are met: | 6 * are permitted provided that the following conditions are met: |
7 * * Redistributions of source code must retain the above copyright notice, | 7 * * Redistributions of source code must retain the above copyright notice, |
8 * this list of conditions and the following disclaimer. | 8 * this list of conditions and the following disclaimer. |
9 * * Redistributions in binary form must reproduce the above copyright notice, | 9 * * Redistributions in binary form must reproduce the above copyright notice, |
10 * this list of conditions and the following disclaimer in the documentation | 10 * this list of conditions and the following disclaimer in the documentation |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 void _initializeRegisters() { | 183 void _initializeRegisters() { |
184 _addType(_pool.getCircleContactStack(), ShapeType.CIRCLE, ShapeType.CIRCLE); | 184 _addType(_pool.getCircleContactStack(), ShapeType.CIRCLE, ShapeType.CIRCLE); |
185 _addType( | 185 _addType( |
186 _pool.getPolyCircleContactStack(), ShapeType.POLYGON, ShapeType.CIRCLE); | 186 _pool.getPolyCircleContactStack(), ShapeType.POLYGON, ShapeType.CIRCLE); |
187 _addType(_pool.getPolyContactStack(), ShapeType.POLYGON, ShapeType.POLYGON); | 187 _addType(_pool.getPolyContactStack(), ShapeType.POLYGON, ShapeType.POLYGON); |
188 _addType( | 188 _addType( |
189 _pool.getEdgeCircleContactStack(), ShapeType.EDGE, ShapeType.CIRCLE); | 189 _pool.getEdgeCircleContactStack(), ShapeType.EDGE, ShapeType.CIRCLE); |
190 _addType(_pool.getEdgePolyContactStack(), ShapeType.EDGE, ShapeType.POLYGON)
; | 190 _addType( |
| 191 _pool.getEdgePolyContactStack(), ShapeType.EDGE, ShapeType.POLYGON); |
191 _addType( | 192 _addType( |
192 _pool.getChainCircleContactStack(), ShapeType.CHAIN, ShapeType.CIRCLE); | 193 _pool.getChainCircleContactStack(), ShapeType.CHAIN, ShapeType.CIRCLE); |
193 _addType( | 194 _addType( |
194 _pool.getChainPolyContactStack(), ShapeType.CHAIN, ShapeType.POLYGON); | 195 _pool.getChainPolyContactStack(), ShapeType.CHAIN, ShapeType.POLYGON); |
195 } | 196 } |
196 | 197 |
197 DestructionListener getDestructionListener() { | 198 DestructionListener getDestructionListener() { |
198 return _destructionListener; | 199 return _destructionListener; |
199 } | 200 } |
200 | 201 |
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 void solveTOI(final TimeStep step) { | 1115 void solveTOI(final TimeStep step) { |
1115 final Island island = toiIsland; | 1116 final Island island = toiIsland; |
1116 island.init(2 * Settings.maxTOIContacts, Settings.maxTOIContacts, 0, | 1117 island.init(2 * Settings.maxTOIContacts, Settings.maxTOIContacts, 0, |
1117 _contactManager.contactListener); | 1118 _contactManager.contactListener); |
1118 if (_stepComplete) { | 1119 if (_stepComplete) { |
1119 for (Body b = bodyList; b != null; b = b._next) { | 1120 for (Body b = bodyList; b != null; b = b._next) { |
1120 b._flags &= ~Body.ISLAND_FLAG; | 1121 b._flags &= ~Body.ISLAND_FLAG; |
1121 b._sweep.alpha0 = 0.0; | 1122 b._sweep.alpha0 = 0.0; |
1122 } | 1123 } |
1123 | 1124 |
1124 for (Contact c = _contactManager.contactList; | 1125 for (Contact c = _contactManager.contactList; c != null; c = c._next) { |
1125 c != null; | |
1126 c = c._next) { | |
1127 // Invalidate TOI | 1126 // Invalidate TOI |
1128 c._flags &= ~(Contact.TOI_FLAG | Contact.ISLAND_FLAG); | 1127 c._flags &= ~(Contact.TOI_FLAG | Contact.ISLAND_FLAG); |
1129 c._toiCount = 0; | 1128 c._toiCount = 0; |
1130 c._toi = 1.0; | 1129 c._toi = 1.0; |
1131 } | 1130 } |
1132 } | 1131 } |
1133 | 1132 |
1134 // Find TOI events and solve them. | 1133 // Find TOI events and solve them. |
1135 for (;;) { | 1134 for (;;) { |
1136 // Find the first TOI. | 1135 // Find the first TOI. |
1137 Contact minContact = null; | 1136 Contact minContact = null; |
1138 double minAlpha = 1.0; | 1137 double minAlpha = 1.0; |
1139 | 1138 |
1140 for (Contact c = _contactManager.contactList; | 1139 for (Contact c = _contactManager.contactList; c != null; c = c._next) { |
1141 c != null; | |
1142 c = c._next) { | |
1143 // Is this contact disabled? | 1140 // Is this contact disabled? |
1144 if (c.isEnabled() == false) { | 1141 if (c.isEnabled() == false) { |
1145 continue; | 1142 continue; |
1146 } | 1143 } |
1147 | 1144 |
1148 // Prevent excessive sub-stepping. | 1145 // Prevent excessive sub-stepping. |
1149 if (c._toiCount > Settings.maxSubSteps) { | 1146 if (c._toiCount > Settings.maxSubSteps) { |
1150 continue; | 1147 continue; |
1151 } | 1148 } |
1152 | 1149 |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 _point.setFrom(input.p1).scale(1 - fraction).add(_temp); | 1936 _point.setFrom(input.p1).scale(1 - fraction).add(_temp); |
1940 return callback.reportFixture(fixture, _point, _output.normal, fraction); | 1937 return callback.reportFixture(fixture, _point, _output.normal, fraction); |
1941 } | 1938 } |
1942 | 1939 |
1943 return input.maxFraction; | 1940 return input.maxFraction; |
1944 } | 1941 } |
1945 | 1942 |
1946 BroadPhase broadPhase; | 1943 BroadPhase broadPhase; |
1947 RayCastCallback callback; | 1944 RayCastCallback callback; |
1948 } | 1945 } |
OLD | NEW |