Skip to content

Commit 32d3d3d

Browse files
committed
feat(events): unit tests & file rename
1 parent 528ff87 commit 32d3d3d

File tree

3 files changed

+848
-15
lines changed

3 files changed

+848
-15
lines changed

actor/shape.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,22 @@ func (b *Box) GetContactFeature(direction mgl64.Vec3, output *[8]mgl64.Vec3, cou
153153
halfSize := b.HalfExtents
154154

155155
// Générer les 4 coins selon la face
156-
if bestAxisIdx == 0 { // Face X
156+
switch bestAxisIdx {
157+
case 0:
157158
x := sign * halfSize.X()
158159
output[0] = mgl64.Vec3{x, -halfSize.Y(), -halfSize.Z()}
159160
output[1] = mgl64.Vec3{x, -halfSize.Y(), halfSize.Z()}
160161
output[2] = mgl64.Vec3{x, halfSize.Y(), halfSize.Z()}
161162
output[3] = mgl64.Vec3{x, halfSize.Y(), -halfSize.Z()}
162163
*count = 4
163-
} else if bestAxisIdx == 1 { // Face Y
164+
case 1:
164165
y := sign * halfSize.Y()
165166
output[0] = mgl64.Vec3{-halfSize.X(), y, -halfSize.Z()}
166167
output[1] = mgl64.Vec3{-halfSize.X(), y, halfSize.Z()}
167168
output[2] = mgl64.Vec3{halfSize.X(), y, halfSize.Z()}
168169
output[3] = mgl64.Vec3{halfSize.X(), y, -halfSize.Z()}
169170
*count = 4
170-
} else { // Face Z
171+
default:
171172
z := sign * halfSize.Z()
172173
output[0] = mgl64.Vec3{-halfSize.X(), -halfSize.Y(), z}
173174
output[1] = mgl64.Vec3{halfSize.X(), -halfSize.Y(), z}
@@ -247,7 +248,7 @@ func (s *Sphere) GetAABB() AABB {
247248
// ComputeMass calculates mass data for the sphere
248249
func (s *Sphere) ComputeMass(density float64) float64 {
249250
// Volume of sphere = (4/3) * π * r³
250-
volume := (4.0 / 3.0) * math.Pi * math.Pow(s.Radius, 3)
251+
volume := (4.0 / 3.0) * math.Pi * s.Radius * s.Radius * s.Radius
251252

252253
return density * volume
253254
}

trigger.go renamed to event.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (e *Events) recordCollisions(constraints []*constraint.ContactConstraint) [
139139
pair := makePairKey(c.BodyA, c.BodyB)
140140
e.currentActivePairs[pair] = true
141141

142-
if c.BodyA.IsTrigger == false && c.BodyB.IsTrigger == false {
142+
if !c.BodyA.IsTrigger && !c.BodyB.IsTrigger {
143143
constraints[n] = c
144144
n++
145145
}
@@ -149,16 +149,6 @@ func (e *Events) recordCollisions(constraints []*constraint.ContactConstraint) [
149149
return constraints
150150
}
151151

152-
// emitSleep emits a sleep event (called from trySleep)
153-
func (e *Events) emitSleep(body *actor.RigidBody) {
154-
e.buffer = append(e.buffer, SleepEvent{Body: body})
155-
}
156-
157-
// emitWake emits a wake event (called from WakeUp)
158-
func (e *Events) emitWake(body *actor.RigidBody) {
159-
e.buffer = append(e.buffer, WakeEvent{Body: body})
160-
}
161-
162152
// processCollisionEvents compares current and previous pairs to detect Enter/Stay/Exit
163153
// Should be called after all substeps
164154
func (e *Events) processCollisionEvents() {

0 commit comments

Comments
 (0)