MCPcopy Create free account
hub / github.com/ByteArena/box2d / CreateChain

Method CreateChain

CollisionB2ShapeChain.go:83–102  ·  view source on GitHub ↗
(vertices []B2Vec2, count int)

Source from the content-addressed store, hash-verified

81}
82
83func (chain *B2ChainShape) CreateChain(vertices []B2Vec2, count int) {
84 B2Assert(chain.M_vertices == nil && chain.M_count == 0)
85 B2Assert(count >= 2)
86 for i := 1; i < count; i++ {
87 // If the code crashes here, it means your vertices are too close together.
88 B2Assert(B2Vec2DistanceSquared(vertices[i-1], vertices[i]) > B2_linearSlop*B2_linearSlop)
89 }
90
91 chain.M_count = count
92 chain.M_vertices = make([]B2Vec2, count)
93 for i, vertice := range vertices {
94 chain.M_vertices[i] = vertice
95 }
96
97 chain.M_hasPrevVertex = false
98 chain.M_hasNextVertex = false
99
100 chain.M_prevVertex.SetZero()
101 chain.M_nextVertex.SetZero()
102}
103
104func (chain *B2ChainShape) SetPrevVertex(prevVertex B2Vec2) {
105 chain.M_prevVertex = prevVertex

Callers 2

TestCPPComplianceFunction · 0.80
CloneMethod · 0.80

Calls 3

B2AssertFunction · 0.85
B2Vec2DistanceSquaredFunction · 0.85
SetZeroMethod · 0.45

Tested by 1

TestCPPComplianceFunction · 0.64