[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - Ruby Extension questions thread

Ruby Extension questions thread

Official forum for the .

Ruby Extension questions thread

Postby mr_luc » Wed Oct 24, 2007 4:59 pm

mr_luc
 
Posts: 4
Joined: Fri Oct 19, 2007 12:47 pm

Re: Ruby Extension questions thread

Postby slembcke » Wed Oct 24, 2007 9:11 pm

I guess this comes down to a lack of documentation on what is and isn't supposed to be opaque in Chipmunk. (I know, bad bad bad) I guess a good rule of thumb is what I've put in the public documentation. If it's not there, then I've considered it unimportant to the end user or an implementation detail (that may change in the future and break things).

To the first question:
I guess I've never really considered a cpSpace to be a container. All my Ruby code is fairly MVC-esque so I end up storing my own list externally anyway. I actually consider what I did with the demo to be a bit of a hack, the simplest possible way to get a Chipmunk space on the screen.

To the second question:
I don't believe I've ever written a CP::Shape::Poly#verts method. Did the ShatteredRuby/Chipmunk folks add one? I actually don't have accessors for attributes on any shape type. Again, in my Ruby code I always have separate model and view objects anyway. Shapes as well weren't really meant to be transparent, simply an internal representation for Chipmunk to use.

The thing is that doing what I do in the demo app just isn't scalable beyond drawing simple outlines of all the objects in the space. I wouldn't really recommend it for any sizable project.

I threw together a simple set of subclasses that should do what you want. Adding that to the actual extension would be a lot more tedious. Is this an OK compromise? I guess I could add it to the extension if people really, really want that.
http://files.slembcke.net/temp/chipmunk_proto.rb
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Ruby Extension questions thread

Postby mr_luc » Thu Oct 25, 2007 5:30 am

Aha! All is clear now. :D

Except for poly.verts, of course. There is definitely a verts method defined for any CP::Shape::Poly; last on the list of poly.methods.sort.

I'm not thinking in terms of large projects, heh; I'm just feeling my way around. But it might be useful to have those methods even in large projects, for debugging. In most game engines, you can toggle the rendering of things like the collision bounding boxes/shapes/convex hulls, for debugging purposes.

Thanks a lot for those extensions -- I'd already added a couple of similar properties to the Space object (my own active_shapes, etc) that basically just hangs onto the data we pass to chipmunk, but after seeing the poly.verts method, I thought I might have been way off. As with a lot of this stuff, when you're learning a new thing, you don't know how much you're missing because you're going about it the wrong way, and how much you're missing because you're just looking in the wrong place.

Thanks a ton for this (and, of course, Chipmunk) I will try this out when I get home from work.
mr_luc
 
Posts: 4
Joined: Fri Oct 19, 2007 12:47 pm

Re: Ruby Extension questions thread

Postby mr_luc » Sat Nov 10, 2007 9:41 pm

Got time for another couple of hours with Chipmunk today. Heh, I haven't had much time for hacking recently; I work on the kill floor at a large pork processing plant that was recently raided by ICE, so there's lots of overtime. For others like me who feel their way around chipmunk in ruby every so often:

- in the extension, body.v.y += num doesn't work the same way that body->v.y += number works in C, but body.v += a vector works just fine. In case you were confused when doing .

Some things I have questions about are the collision pair functions. The collision_type for my shapes is an integer, which by default seems to be 4 for both active and static shapes. I add a shape and set its type to 5. Then, I try to define a collision function with this code: (heh, I'm just feeling my way along here, be kind!)

chipgl.space.add_collision_func(type1, type2) { p "hello" }

where type1 and type2 are set from the collision_type properties of the 2 shapes added to the space, one active and one static. I can clearly see the shapes interacting; I've sort of ported the demo code to ruby (well, actually, I just realized that I haven't even written line segment drawing, just polys and circles, but it's enough to know it's working and see what's happening in the spaces I've mucked up so far).

I could be way off, because I am pretty new to Ruby extensions.
mr_luc
 
Posts: 4
Joined: Fri Oct 19, 2007 12:47 pm

Re: Ruby Extension questions thread

Postby slembcke » Sun Nov 11, 2007 1:50 pm

Well the first issue is due to the body.v method returning a new vector. It really should be returning a vector object that points to the original vector in the body struct. For the record, I'm actually missing quite a bunch of stuff in the extension. Marshalling methods, hash, equals, etc.

For the second issue with collision pair functions, are you using the latest Chipmunk? In the Ruby extension, I use the object ID as the collision type internally. That way you can use any object (class objects are usually pretty handy here). Can't really remember when I changed it, but getting the collision type used to return the object id, and not the object. The default collision type was nil, which has an object id of 4. That might be were some of your confusion comes from.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest

cron