MackeyK24 Posted January 4, 2017 Share Posted January 4, 2017 I really need to be able to hook into physics collision detection... There used to be a mesh.onPhysicsCollide that would have worked perfectly for my collision detection system (I basically don't require the imposter filter part for collision detection... I will filter based off mesh.metadata tags). Now using the registerOnPyhsicsCollide DOES NOT WORK without some kind of imposter (even with the otherImposter.length === 0). The problem is the unregister DOES NOT find if you pass null imposter or empty imposter array... you gotta pass an actual imposter to filter or you WONT be able to unregister.... and you will leak. I need basic collision detection support... I will handle (filter) what should be imposter collision event should get dispatched. I suggest the SMALL change to the babylon.physicsImpostor class: /** * Legacy collision detection event support */ public onCollideEvent: (collider:BABYLON.PhysicsImpostor, collidedWith:BABYLON.PhysicsImpostor) => void = null; //event and body object due to cannon's event-based architecture. public onCollide = (e: { body: any }) => { var otherImpostor = this._physicsEngine.getImpostorWithPhysicsBody(e.body); if (otherImpostor) { // Legacy collision detection event support if (this.onCollideEvent) { this.onCollideEvent(this, otherImpostor); } if (!this._onPhysicsCollideCallbacks.length) return; this._onPhysicsCollideCallbacks.filter((obj) => { return obj.otherImpostors.indexOf(otherImpostor) !== -1 }).forEach((obj) => { obj.callback(this, otherImpostor); }) } } What do you think @Deltakosh @Sebavan @RaananW ... OR Should i just fork my own BabylonJS Toolkit Version of the framework... And i will just use my own build for the toolkit: /Assets/Babylon/Library/babyblon.bjs (Which might not be a BAD idea... At least i would have better control of the main babylonjs library and the API that is necessary for me to make the KOOL toolkit features i have been working on) I dunno ... Please folks... Weigh in your thoughts before i do anything drastic with the toolkit libraries Quote Link to comment Share on other sites More sharing options...
jschwuch Posted January 4, 2017 Share Posted January 4, 2017 I think this would be a nice addition! Quote Link to comment Share on other sites More sharing options...
adam Posted January 4, 2017 Share Posted January 4, 2017 I'm sure this problem can be solved without forking BJS. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 4, 2017 Share Posted January 4, 2017 Forking is the worst idea ever as you will have to maintain it alone. We won't be able to keep your tool in the repo as we cannot promote and support many version of the engine. I'm pretty sure you can discuss with @RaananW to find the best way to fit your needs Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 5, 2017 Author Share Posted January 5, 2017 9 hours ago, Deltakosh said: Forking is the worst idea ever as you will have to maintain it alone. We won't be able to keep your tool in the repo as we cannot promote and support many version of the engine. I'm pretty sure you can discuss with @RaananW to find the best way to fit your needs OK... WONT ever create a separate forked version (except for testing features and submitting PR's of course) Will wait for @RaananW to make a decision Quote Link to comment Share on other sites More sharing options...
dbawel Posted January 5, 2017 Share Posted January 5, 2017 I recommend you ask @Pryme8 about a solution to this, as he has helped me great deal in handling physics releated issues in projects I've had to deliver. He thins WAY out of the box on matters such as these. DB Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 5, 2017 Share Posted January 5, 2017 If I have tomorrow I will take a look, I doubt I will though I am going to bed now and am doing a move to a new house tomorrow so Ill be busy. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 5, 2017 Author Share Posted January 5, 2017 I actually have a working solution... waiting for @RaananW to approve it. This is the modified 'onCollide' from the babylon.physicsImposter.ts: /** * Legacy collision detection event support */ public onCollideEvent: (collider:BABYLON.PhysicsImpostor, collidedWith:BABYLON.PhysicsImpostor) => void = null; //event and body object due to cannon's event-based architecture. public onCollide = (e: { body: any }) => { var otherImpostor = this._physicsEngine.getImpostorWithPhysicsBody(e.body); if (otherImpostor) { // Legacy collision detection event support if (this.onCollideEvent) { this.onCollideEvent(this, otherImpostor); } if (!this._onPhysicsCollideCallbacks.length) return; this._onPhysicsCollideCallbacks.filter((obj) => { return obj.otherImpostors.indexOf(otherImpostor) !== -1 }).forEach((obj) => { obj.callback(this, otherImpostor); }) } } Works perfect... and NO UNREGISTER LEAKS Quote Link to comment Share on other sites More sharing options...
adam Posted January 5, 2017 Share Posted January 5, 2017 @MackeyK24 No need to wait. He responded to your PR letting you know what needs to change in order for it to be approved. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 5, 2017 Author Share Posted January 5, 2017 (edited) @RaananW @Deltakosh @adam ME BEING A DUMB ASS ... NEVER MIND Edited January 5, 2017 by MackeyK24 Dumb ass Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 5, 2017 Author Share Posted January 5, 2017 SHIT.... @RaananW @Deltakosh @adam ... I AM A TOTAL DUMB ASS (AGAIN)... I AM SOOOOOO SORRY... BEING SOOOO THICK HEADED... I DIDNT REALLY CATCH WHAT YOU WERE SAYING.... Basically you just wanted my dumb ass to check before the 'getImposterWithPhysicsBody' if there are NO CALLBACK AND NO onCollideEvent handler... DONE MOVE DOWN AS I DID... JUST FIX UP TO INCLUDE the !onCollideEvent check... I feel so stupid.... sorry for all the HU-HAH !!! Pryme8 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 6, 2017 Share Posted January 6, 2017 NO WORRY:) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.