aalavandhaann / blueprint-js

The Javascript es6 version of the original furnishup/blueprint3d. Need some royalty free low poly models for the inventory. Can someone help me with this?
MIT License
504 stars 158 forks source link

Bug on Collision Detection #26

Closed CanKavaloglu closed 5 years ago

CanKavaloglu commented 5 years ago

Describe the bug The collision detection routine does not seem to be working properly.

To Reproduce Steps to reproduce the behavior:

  1. Change the return statement to false inside the if statement in 'isValidPoisiton' in 'FloorItem' class.
  2. 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.

aalavandhaann commented 5 years ago

I encountered this. I have fixed this by adding a new method pointInPolygon2. Yet to add to the commit.