Pkeod
November 3, 2020, 5:46am
1
I’m trying to mimic something like this
Box2DDragFixture.zip (3.5 KB)
Here’s my wip. I’m not sure how phaser does it. I tried making the joint 0 length but it’s still bouncy around the joint point which I don’t want. The phaser example does a good job o finding the point and sticking to it, no matter what I do with Defold it’s always bouncy and never finds the point easily (or is not strong enough to follow the mouse / even then it feels weird).
Any ideas on how to improve this?
Videos below showing current behavior / closer to what I want
1 Like
Pkeod
November 3, 2020, 6:17am
2
I think I want a Mouse Joint?
defold/engine/physics/src/box2d/Box2D/Dynamics/Joints at 869a87718757bdb7bfd6ed078047fa7bfb451de9 · defold/defold · GitHub
So it would need to be added here and a few other places with the right settings…
return true;
}
bool GetJointParams2D(HWorld2D world, HJoint _joint, dmPhysics::JointType type, ConnectJointParams& params)
{
float inv_scale = world->m_Context->m_InvScale;
b2Joint* joint = (b2Joint*)_joint;
params.m_CollideConnected = joint->GetCollideConnected();
switch (type)
{
case dmPhysics::JOINT_TYPE_SPRING:
{
b2DistanceJoint* typed_joint = (b2DistanceJoint*)joint;
params.m_SpringJointParams.m_Length = typed_joint->GetLength() * inv_scale;
params.m_SpringJointParams.m_FrequencyHz = typed_joint->GetFrequency();
params.m_SpringJointParams.m_DampingRatio = typed_joint->GetDampingRatio();
}
break;
case dmPhysics::JOINT_TYPE_FIXED:
Repository search results · GitHub
britzl
November 3, 2020, 7:16am
3
From the description it does indeed sound like what you want. Is there an equivalent kind of joint in Bullet?
Pkeod
November 3, 2020, 7:24am
4
I think btPoint2PointConstraint would be it?
Existing joints don’t work in 3D though, they are only for 2D?
We chose the first set of constraints since there were versions of them in 3D as well.
Pkeod
November 3, 2020, 7:55am
6
What do you think the naming should be for a joint like this?
I’ve made an issue for the feature Add physics.JOINT_TYPE_POINT · Issue #5309 · defold/defold · GitHub
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/bullet/bullet-2.77.zip under demos / opengl / DemoApplication.cpp there is a demo of mouse picking / moving
1 Like