| 153 | var b2_gjkCalls, b2_gjkIters, b2_gjkMaxIters int |
| 154 | |
| 155 | func (p *B2DistanceProxy) Set(shape B2ShapeInterface, index int) { |
| 156 | switch shape.GetType() { |
| 157 | case B2Shape_Type.E_circle: |
| 158 | { |
| 159 | circle := (shape).(*B2CircleShape) |
| 160 | p.M_vertices = []B2Vec2{circle.M_p} |
| 161 | p.M_count = 1 |
| 162 | p.M_radius = circle.M_radius |
| 163 | } |
| 164 | break |
| 165 | |
| 166 | case B2Shape_Type.E_polygon: |
| 167 | { |
| 168 | polygon := shape.(*B2PolygonShape) |
| 169 | p.M_vertices = polygon.M_vertices[:] |
| 170 | p.M_count = polygon.M_count |
| 171 | p.M_radius = polygon.M_radius |
| 172 | } |
| 173 | break |
| 174 | |
| 175 | case B2Shape_Type.E_chain: |
| 176 | { |
| 177 | chain := shape.(*B2ChainShape) |
| 178 | B2Assert(0 <= index && index < chain.M_count) |
| 179 | |
| 180 | p.M_buffer[0] = chain.M_vertices[index] |
| 181 | if index+1 < chain.M_count { |
| 182 | p.M_buffer[1] = chain.M_vertices[index+1] |
| 183 | } else { |
| 184 | p.M_buffer[1] = chain.M_vertices[0] |
| 185 | } |
| 186 | |
| 187 | p.M_vertices = p.M_buffer[:] |
| 188 | p.M_count = 2 |
| 189 | p.M_radius = chain.M_radius |
| 190 | } |
| 191 | break |
| 192 | |
| 193 | case B2Shape_Type.E_edge: |
| 194 | { |
| 195 | edge := shape.(*B2EdgeShape) |
| 196 | p.M_vertices = []B2Vec2{edge.M_vertex1, edge.M_vertex2} |
| 197 | p.M_count = 2 |
| 198 | p.M_radius = edge.M_radius |
| 199 | } |
| 200 | break |
| 201 | |
| 202 | default: |
| 203 | B2Assert(false) |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | type B2SimplexVertex struct { |
| 208 | WA B2Vec2 // support point in proxyA |