Results 1 to 12 of 12

Thread: Overriding PhysicsObject::on_collision_begin/end not working

  1. #1

    Question [SOLVED] Overriding PhysicsObject::on_collision_begin/end not working

    I've been learning Clanlib for a while now and with the help of the examples I've managed to get as far as getting physics working. Now i've bumped into a problem with overriding PhysicsObject::on_collision_begin/end. I have a base class for all game objects (showing only relevant parts):

    Code:
    	class LevelObjectBase : public clan::PhysicsObject
    	{
    	public:
    		virtual void on_collision_begin(clan::Body &b);
    		virtual void on_collision_end(clan::Body &b);
    		virtual bool should_collide_with(clan::Body &b);
    	protected:
    		clan::Body m_body;
    		clan::Fixture m_fixture;
    
    	};
    And other object derive from the above class like

    Code:
    class BlockObject : public DestroyableObject, public clan::PolygonShape
    {
    public:
    	BlockObject(clan::Canvas *canvas, clan::Sprite *sprite, unsigned int health, 
    		clan::PhysicsContext &pc, const std::string &name = "block");
    };
    
    why::BlockObject::BlockObject(clan::Canvas *canvas, clan::Sprite *sprite, unsigned int health,
    	clan::PhysicsContext &pc, const std::string &name) :
    	DestroyableObject(canvas, sprite, health, name), clan::PolygonShape(pc)
    {
    	using namespace clan;
    	set_as_box((float)get_width()/2, (float)get_height()/2);
    
    	BodyDescription bd(pc);
    	bd.set_type(BodyType::body_static);
    
    	m_body = Body(pc, bd);
    	
    	FixtureDescription fd(pc);
    	fd.set_density(1.0f);
    	fd.set_shape(*this);
    	m_fixture = Fixture(pc, m_body, fd);
    }
    The game loop simply calls PhysicsWorld::step() after I'm done drawing. The objects are moving as they are supposed to and collisions also work as expected. However, the overridden functions are not being called when collision happens. I checked the Roadgeddon example and I didn't see anything that has been done differently (at least anything directly related to collisions).

    Am I missing something?

    P.S. Any chance that the documentation will updated with a bit more details? There isn't much explanations on what to do/when to do/what not do etc. The examples help but it's still extra work if everything needs to be searched from the examples.

    TIA
    Last edited by vdell; 03-24-2014 at 11:59 AM. Reason: Solved

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Quote Originally Posted by vdell View Post
    P.S. Any chance that the documentation will updated with a bit more details? There isn't much explanations on what to do/when to do/what not do etc. The examples help but it's still extra work if everything needs to be searched from the examples.
    No, there is little chance.

    Unfortunately the state is this:
    To create documentation, you need to be proficient at programming with ClanLib
    When proficient, you no longer require documentation.
    It is boring to create documentation.

    You are welcome to submit documentation patches via github.

    With reference to your question. I think you are on your own with that one.

    ClanLib is modular, developers only use and specialise in specific components of ClanLib.
    For example, I only use clanCore, clanDisplay and clanGL.

    I don't know anyone that currently uses clanPhysics2D.
    Maybe I'll be proved wrong

  3. #3

    Thumbs down

    Quote Originally Posted by rombust View Post
    No, there is little chance.

    Unfortunately the state is this:
    To create documentation, you need to be proficient at programming with ClanLib
    When proficient, you no longer require documentation.
    It is boring to create documentation.

    You are welcome to submit documentation patches via github.
    I'm kind of baffled that someone would think so little about documentation and the importance of it. Sure, after one masters the usage of a library, there's less use for the docs but how can one master it without documentation? By looking at the source? With proper documentation the learning process would be a lot quicker and that would undoubtedly attract more users and developers to ClanLib (which I'm guessing is the idea when a library is released to the public but maybe I'm wrong). As an example, if you compare the documentation of ClanLib to the documentation of the Boost libraries, which one seems more professional? I understand that Boost is maybe not the best example, because it has a lot more developers, but its docs are pretty good.

    Quote Originally Posted by rombust View Post
    With reference to your question. I think you are on your own with that one.
    I guess I have to cross my fingers and hope for the best ...

  4. #4

    Thumbs up

    Solution: Call m_body.set_data(this) from the derived class.

    Quote Originally Posted by documentation
    void clan::Body::set_data ( PhysicsObject * data )
    Set the physics object object that is going to process collision events.

  5. #5
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Quote Originally Posted by vdell View Post
    I'm kind of baffled that someone would think so little about documentation and the importance of it.....

    My comment is through experience of using ClanLib since around year 2000.

    Nobody is denying that ClanLib documentation is extremely limited, and it really does need improving.

    Before around year 2000, ClanLib documentation was a lot better. There were numerous tutorials explaining how to do things. A book even exists with a chapter dedicated to ClanLib. Back then, the code base was tiny.

    Since then, 3 developers (including myself) have written a lot of documentation, and spent a lot of personal time doing it. As you can tell, we have only just scratched the surface.
    We no longer have any free time to write documentation, with family and work taking priority. In our limited free time, we prefer to code as a hobby, not writing documentation.

    ClanLib is unique in itself. There is no “management”. You have just as much say in it, as I do. We discuss things on IRC if breaking changes are beneficial.

    We never tell anyone “you should do this”, else there is usually a rude response. Basically saying “If you don't like it, fix it, and post a patch on github”.

    Why other libraries have better documentation? Well, it's the type of library. ClanLib isn't cool to develop. People love using it, just not developing for it.

    Have a look at this thread http://www.rtsoft.com/forums/showthr...ion-of-ClanLib ... it covers about all of it!

  6. #6
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    For interest, about 3 years ago, we had a wiki for editing docs. Nobody used it. ... Except spammers
    So last year we moved the documentation to ClanLib\Documentation in the source code.

  7. #7

    Default

    Quote Originally Posted by rombust View Post
    For interest, about 3 years ago, we had a wiki for editing docs. Nobody used it. ... Except spammers
    So last year we moved the documentation to ClanLib\Documentation in the source code.
    That's a shame, although it does streamline big doc patches. It might be a good idea to add documentation guidelines to the code guidelines file to ensure future patches begin trending towards better code transparency. Something that strongly encourages a "document as you go" approach. It's really not as time consuming as everyone thinks, and it would make the engine much more approachable.

    Either way, it's just a suggestion.

  8. #8

    Default

    Quote Originally Posted by rombust View Post
    No, there is little chance.

    Unfortunately the state is this:
    To create documentation, you need to be proficient at programming with ClanLib
    When proficient, you no longer require documentation.
    It is boring to create documentation.
    Hmm, weird. I wrote a pretty long post about the topic and the system said it will be checked by moderators before being posted, but it's still not visible. Well, long story short: IMHO, when a library is released to the public it should be a top priority to take care of the documentation, as that will undoubtedly help in adopting the lib to a project and thus create a bigger and more active community. A developer calling documentation "boring" is kinda scary from a library users' point of view...

  9. #9

    Default

    Quote Originally Posted by vdell View Post
    Hmm, weird. I wrote a pretty long post about the topic and the system said it will be checked by moderators before being posted, but it's still not visible. Well, long story short: IMHO, when a library is released to the public it should be a top priority to take care of the documentation, as that will undoubtedly help in adopting the lib to a project and thus create a bigger and more active community. A developer calling documentation "boring" is kinda scary from a library users' point of view...
    Don't sell them short. The code base is clean and seems to be well designed, and they do their best to keep patching it and answering questions. That's a lot more than some other engines offer. They've got a great little operation set up here, they just need to embrace common documentation practices rather than turning it into a chore, which isn't the easiest thing to do at the drop of a hat.

  10. #10
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Quote Originally Posted by vdell View Post
    Hmm, weird. I wrote a pretty long post about the topic and the system said it will be checked by moderators before being posted, but it's still not visible.
    Strange. Also, it said my post was also moderated .Might be okay now

    - - - Updated - - -

    Quote Originally Posted by vdell View Post
    A developer calling documentation "boring" is kinda scary from a library users' point of view...
    Yes, and it's wrong I admit that.

    In my opinion, with hindsight, many years ago, maybe ClanLib should have had a policy "submitting a patch with added features will not accepted without corresponding documentation".

    Difficult to know. Pro's and Con's either way.

  11. #11

    Default

    Quote Originally Posted by rombust View Post
    Yes, and it's wrong I admit that.

    In my opinion, with hindsight, many years ago, maybe ClanLib should have had a policy "submitting a patch with added features will not accepted without corresponding documentation".

    Difficult to know. Pro's and Con's either way.
    Nothing stopping you guys from adding a standard now. Especially if you want the development community to grow. Subsequent updates/patches, regardless of features added could require corresponding documentation that meets certain standards. Eventually, desire to release a new version will overpower laziness.

    A little extra effort now will make development/growth easier for both developers and users.

  12. #12

    Thumbs up

    Quote Originally Posted by Seltzer View Post
    Don't sell them short. The code base is clean and seems to be well designed, and they do their best to keep patching it and answering questions. That's a lot more than some other engines offer. They've got a great little operation set up here, they just need to embrace common documentation practices rather than turning it into a chore, which isn't the easiest thing to do at the drop of a hat.
    Yeah, no objections on that. The library has been easy to use, even for a game developer newbie like me, and the examples help a lot. However, in the case where examples are unable to help it's the documentation and the community that are the next place to look for answers. The way I view it is that the examples are only a supplement for the documentation. Anyway, I'm pretty sure I've made my point clear and hopefully it will have an impact on the future development.


Similar Threads

  1. Password isn't working
    By cupcake in forum Bugs & Glitches
    Replies: 11
    Last Post: 07-27-2013, 06:55 AM
  2. 3D acceleration not working
    By Pap in forum Official ClanLib SDK Forums
    Replies: 12
    Last Post: 07-13-2013, 10:23 PM
  3. What are you working on?
    By whisperstorm in forum Novashell Game Creation System
    Replies: 8
    Last Post: 06-19-2007, 03:52 PM
  4. I could not get it working
    By in forum Other RTsoft Games
    Replies: 5
    Last Post: 06-03-2003, 06:13 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •