Skip to content

Optimize collision detection #4

@SIY1121

Description

@SIY1121

Optimize collision detection using algorithm such as Quaternary Spatial Partitioning.

// TODO reduce the computational cost
let remainingContributions = 0
this.blocks
.filter((b) => b.life > 0)
.forEach((b) => {
const d = intersectDirection(this.ball, b)
// the ball hit the block
if (d !== Direction.None) {
this.ball.onCollide(d)
b.onCollide()
this.score += b.origianlLife
}
remainingContributions += b.life
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions