Skip to content

[~] Game: Enhance CollisionManager#52

Open
ecrinyildiz wants to merge 7 commits intomainfrom
update-collision-manager
Open

[~] Game: Enhance CollisionManager#52
ecrinyildiz wants to merge 7 commits intomainfrom
update-collision-manager

Conversation

@ecrinyildiz
Copy link
Copy Markdown
Collaborator

  • Seperate detection and resolve session
  • Rearrange inline pair_hash struct, so it can be reusable
  • Create alias for SpatialGrid and CollisionsObject to reduce complexity
  • Remove dynamic casting while calculating the center of the game objects, now call the getCenter() function handle the casting operation.

Remark:
Read the issue #51

- Seperate detection and resolve session
- Rearrange inline `pair_hash` struct, so it can be reusable
- Create alias for `SpatialGrid` and `CollisionsObject` to reduce complexity
- Remove dynamic casting while calculating the `center` of the game objects, now call the `getCenter()` function handle the casting operation.
@erincyldz
Copy link
Copy Markdown
Owner

LGTM. Did you test the code and see everything worked perfect? @ecrinyildiz

@ecrinyildiz
Copy link
Copy Markdown
Collaborator Author

This PR does not introduce any new features or remove existing ones; it only involves refactoring. That's why the behavior of the code remains unchanged from its previous state. So, I did not conduct additional tests. Any issues that may arise would likely have existed in the prior implementation.

Comment thread src/GameObject.cpp
{
if(stable)
{
m_velocity *= 0;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of multiplication, you can directly set to zero

if (stable && m_velocity != 0) // Only modify velocity if needed
    {
        m_velocity = 0;
    }

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vector2D class doesnt have a copy constructor for scalar values, thats why. You would have seen this if you check how the class is implemented in the first place :)

Comment thread src/GameObject.cpp
}
else
{
m_velocity *= 0;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you choose multiplication instead of directly set?

Copy link
Copy Markdown
Owner

@erincyldz erincyldz Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I explained on the other comment. Refer to this answer please.

@ecrinyildiz
Copy link
Copy Markdown
Collaborator Author

you didnt even care my previous comments, anyway when i checkout the branch it doesnt look like weird to me. but it doesnt look like the infinite bounce problem was fixed when objects collide.

@erincyldz
Copy link
Copy Markdown
Owner

you didnt even care my previous comments, anyway when i checkout the branch it doesnt look like weird to me. but it doesnt look like the infinite bounce problem was fixed when objects collide.

can you do your explanation more detailed, like what do you mean "it doesnt looks like", what happens when you run the program? Does it keep bouncing and counting up? Does it even plays the collision audio?

@ecrinyildiz
Copy link
Copy Markdown
Collaborator Author

i didnt notice the collision sounds, but im sure that i created a scenario where two objects collide and never separate while the collision count to increase infinitely. i dont have a specific steps to reproduce this problem. it happened while i randomly testing

erincyldz and others added 4 commits March 15, 2026 16:15
…es the game not launchable since it gets stuck over a corrupted vector loop
- Seperate detection and resolve session
- Rearrange inline `pair_hash` struct, so it can be reusable
- Create alias for `SpatialGrid` and `CollisionsObject` to reduce complexity
- Remove dynamic casting while calculating the `center` of the game objects, now call the `getCenter()` function handle the casting operation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants