Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segment query first, sometimes failing #234

Closed
DwiYI opened this issue Jun 24, 2023 · 9 comments
Closed

Segment query first, sometimes failing #234

DwiYI opened this issue Jun 24, 2023 · 9 comments

Comments

@DwiYI
Copy link

DwiYI commented Jun 24, 2023

Can anyone help me, why this happen ?.
I am following example from query demo but cpSpaceSegmentQueryFirst sometimes failing.

What kind of possible problem has this caused?
screen-recording-6-24-2023-10-56-00-am_AkNf3Zb5

@DwiYI DwiYI changed the title Segment query first sometimes failing Segment query first, sometimes failing Jun 24, 2023
@aismann
Copy link
Contributor

aismann commented Jun 24, 2023

It works here

@DwiYI
Copy link
Author

DwiYI commented Jun 24, 2023

That's right, the demo is working fine. but not on my code. I don't know how to do debug that because example working fine. Do you know possible cause of that ?. its binding

@aismann
Copy link
Contributor

aismann commented Jun 24, 2023

Look at your code ;)

@DwiYI
Copy link
Author

DwiYI commented Jun 24, 2023

this is dart binding

late SegmentQueryInfo info;
(Shape shape, SegmentQueryInfo info) segmentQueryFirst({required Vector2 start, required Vector2 end, required double radius, required ShapeFilter filter}) {
  var sh = _bindings.cpSpaceSegmentQueryFirst(_space, start.toCpVect().ref, end.toCpVect().ref, radius, filter._toPointer().ref, 
           info._segmentQueryInfo);
  return (Shape._fromPointer(sh), info);
}

this is query code


 widget.game.physicUpdateAfter = (p0) {
      var (lq.Shape shape, lq.SegmentQueryInfo info) = widget.game.space.segmentQueryFirst(start: start, end: end, radius: 10, filter: shapeFilterAll);
      if (shape.isExist) {
        poi = info.point;
        nor = info.normal;
        alp = info.alpha;
        lineDraw1 = true;
        desc = 'Segment Query: Dist(${alp * (end - start).length}) Normal(${nor.x}, ${nor.y})';
      } else {
        lineDraw1 = false;
        alp = 1;
        desc = 'Segment Query (None)';
      }
    };

@aismann
Copy link
Contributor

aismann commented Jun 24, 2023

work this correct : shape.isExist ?

@DwiYI
Copy link
Author

DwiYI commented Jun 24, 2023

thats, only check against null,

@aismann
Copy link
Contributor

aismann commented Jun 24, 2023

add some debug outputs on your code.
Hope this is helping you.

@aismann
Copy link
Contributor

aismann commented Jun 24, 2023

thats, only check against null,

Thats seems not correct ;) the object isn't null
check all input parameters:

@DwiYI
Copy link
Author

DwiYI commented Jun 26, 2023

Thank you for your suggestion. The problem come from filter parameter. My code sending garbage value. I will close this.

@DwiYI DwiYI closed this as completed Jun 26, 2023
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

No branches or pull requests

2 participants