Bug on Collision Detection
Closed this issue · 1 comments
Describe the bug
The collision detection routine does not seem to be working properly.
To Reproduce
Steps to reproduce the behavior:
- Change the return statement to false inside the if statement in 'isValidPoisiton' in 'FloorItem' class.
- Just move an floor item through a wall or outside the model.
Expected behavior
When an item is moved through a wall or to outside of the walls (property), the movement should be disabled. However, the current implementation work strange, mostly just the opposite of what it should be doing.
Additional context
There was a bug in 'pointInPolygon' function. The if statement which makes a call to 'lineLineIntersect' method was not passing with proper parameters properly. I have change the call into:
if (Utils.lineLineIntersect(start, point, {x: tFirstCorner.x, y: tFirstCorner.y}, {x: tSecondCorner.x, y: tSecondCorner.y})) {
tIntersects++;
}
The change is on 'firstCorner' and 'secondCorner'. Now they are being passed like tuples.
Anyways, even after fixing this bug, the is something wrong with the computation I guess.
I encountered this. I have fixed this by adding a new method pointInPolygon2. Yet to add to the commit.