Opened 12 years ago

Closed 12 years ago

#990 closed enhancement (fixed)

Unpin object

Reported by: erikos Owned by: brian
Priority: Low Milestone: Unspecified
Component: Physics Version: Unspecified
Severity: Minor Keywords:
Cc: asaf, brian, sirkne@…, garycmartin Distribution/OS: Unspecified
Bug Status: New

Description

I could only find out how to delete a whole object.

Change History (10)

comment:1 Changed 12 years ago by erikos

  • Summary changed from Unping something to Unpin object

comment:2 Changed 12 years ago by garycmartin

  • Bug Status changed from Unconfirmed to New
  • Cc asaf added
  • Priority changed from Unspecified by Maintainer to Low
  • Severity changed from Unspecified to Minor
  • Status changed from new to accepted

Thanks for the feedback Simon! Yes, understood, deleting an object removes its associated links/motors/pins, and is currently the only way of removing them if you have fat fingers :-) I'm not sure the underlying API responsible (Elements/Box2D?) currently allows such refined editing options to currently remove such things.

Asaf: In your journeys into Elements/Box2D API, does such a request seem potentially feasible?

comment:3 follow-up: Changed 12 years ago by asaf

The method called in tools.py to destroy a body belongs to Box2D. There is a method to destroy joints as well. The destroy tool calls a method from elements called get_bodies_at_pos and then calls DestroyBody. We only need to create a similar method like get_joints_at_pos and then call DestroyJoint.

comment:4 in reply to: ↑ 3 ; follow-up: Changed 12 years ago by garycmartin

Replying to asaf:

The method called in tools.py to destroy a body belongs to Box2D. There is a method to destroy joints as well. The destroy tool calls a method from elements called get_bodies_at_pos and then calls DestroyBody. We only need to create a similar method like get_joints_at_pos and then call DestroyJoint.

Thanks Asaf, I guess the trick will be making sure a single destroy tool smartly does either operation based on context. i.e. if you are near enough to a joint/pin/motor remove it, otherwise try to destroy the body.

comment:5 in reply to: ↑ 4 Changed 12 years ago by brian

  • Cc brian sirkne@… added

Looking through the pybox2d docs, the B2Body.GetJointList() should return a list of b2JointEdges, which have an attribute .joint which can be destroyed with self.game.world.world.DestroyJoint(joint)

But I'm finding that .GetJointList() is returning a b2JointEdge (instead of a list of edges), and that the b2JointEdge returned does not have an attribute .joint.

Maybe we need to upgrade the version of pybox2d in Physics to get this functionality? CCing Kne -- what do you think?

Replying to garycmartin:

Thanks Asaf, I guess the trick will be making sure a single destroy tool smartly does either operation based on context. i.e. if you are near enough to a joint/pin/motor remove it, otherwise try to destroy the body.

+1, that UI makes sense.

comment:6 Changed 12 years ago by kne

Hello,

Yes, you will need to upgrade if you need the joint list. It unfortunately was not properly accessible before (I think) 2.0.2b1. There are also quite a few additional features, stability changes, and bug fixes that should entice you to upgrade.

Any other questions/comments, feel free to let me know.

comment:7 Changed 12 years ago by brian

Tracking the upgrade to pyBox2D 2.0.2b1 on ticket: http://dev.sugarlabs.org/ticket/1002

I'll see how involved this upgrade is, and whether a temporary branching makes sense.

comment:8 Changed 12 years ago by brian

What we'll do will be similar to this (but requires newest pyBox2D for the .joint attribute):

http://dev.laptop.org/git/activities/bridge/tree/tools.py?id=ec034421db0933df5065dd681320ea39e96fc616#n220

comment:9 Changed 12 years ago by brian

  • Owner changed from garycmartin to brian
  • Status changed from accepted to assigned

comment:10 Changed 12 years ago by brian

  • Cc garycmartin added
  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.