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

sleep problem's and margin #107

Open
lo-th opened this issue May 2, 2022 · 9 comments
Open

sleep problem's and margin #107

lo-th opened this issue May 2, 2022 · 9 comments

Comments

@lo-th
Copy link

lo-th commented May 2, 2022

Hi i can't set sleep at start ? work with gravity 0
body.sleep() don't work i guess ?

also what about margin ? are the shape have margin ?

@jcyuan
Copy link
Contributor

jcyuan commented May 11, 2022

show some of your code please.
body.sleep should work i think.

no, there is no margin on a body, it's unnecessary since you can create your body a bit larger then your display game object so that it looks like there is margin.

@lo-th
Copy link
Author

lo-th commented May 11, 2022

Hi mm no body.sleep don't work
code is like
https://lo-th.github.io/phy/#basic

at start object should sleep
i put a timeout to wakeup

but i see original rapier have same problem's cause by gravity

@jcyuan
Copy link
Contributor

jcyuan commented May 12, 2022

        const bdDesc = RigidBodyDesc.dynamic();
        bdDesc.setCanSleep(true);
        bdDesc.setTranslation(4, 0);

        const coDesc = ColliderDesc.ball(.3);

        const bd = context.world.createRigidBody(bdDesc);
        const co = context.world.createCollider(coDesc, bd.handle);

        let i = 0;
        setInterval(function() {
            if (i % 2) {
                bd.sleep();
                console.log("sleep");
            }
            else {
                bd.wakeUp();
                console.log("wakeup");
            }
            i++;
        }, 100);

and result:

sleep.mp4

(ball in grey means it's sleeping)

so it just works normally.

@jcyuan
Copy link
Contributor

jcyuan commented May 12, 2022

btw, set world's gravity as 0, the same result. it will blink normally.

@jcyuan
Copy link
Contributor

jcyuan commented May 12, 2022

ah, i know what you mean now, you wanna make it sleeping when it's just created, right?
i think not unless you call bd.sleep() in next frame.

@sebcrozet i think we need to add sleeping in RigidBodyDesc for an initial status?

@sebcrozet
Copy link
Member

i think we need to add sleeping in RigidBodyDesc for an initial status?

That’s correct, this needs to be added.

@lo-th
Copy link
Author

lo-th commented May 12, 2022

yes cool
i use 3d version, i test soon 2d
also i note strange collision for block touching ( that why i need know if margin )

@jcyuan
Copy link
Contributor

jcyuan commented May 13, 2022

2d & 3d used the shared code, so it was added for both.

for collision, if you mean penetration, try enable CCD, and limit velocity etc.

@lo-th
Copy link
Author

lo-th commented May 13, 2022

yes thank's i will release my phy engin soon
with oimo ammo physx and yes rapier :)

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

3 participants