single acting cylinder

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: single acting cylinder

Postby blackbird_dream » Thu Nov 15, 2018 3:27 am

I believe the issue comes from the changes made in Unity. I'll check when I have time soon.
User avatar
blackbird_dream
 
Posts: 279
Joined: Wed Jun 07, 2006 3:08 pm
Location: Italy

Re: single acting cylinder

Postby blackbird_dream » Thu Nov 15, 2018 10:06 am

Code: Select all
   callback(userData, &m_minForce, sizeof(dFloat));
missing
in
Code: Select all
void dCustomSliderActuator::Serialize(NewtonSerializeCallback callback, void* const userData) const

and
Code: Select all
void dCustomSliderActuator::Deserialize(NewtonSerializeCallback callback, void* const userData) const

File dCustomSliderActuator.cpp

Code: Select all
MinForce = m_minForce;
missing
in
Code: Select all
public class NewtonSliderActuator : NewtonJoint
{
    public override void InitJoint()

File NewtonSlider.cs


With these fixes it works fines.
Cheers
Last edited by blackbird_dream on Thu Nov 15, 2018 10:52 am, edited 1 time in total.
User avatar
blackbird_dream
 
Posts: 279
Joined: Wed Jun 07, 2006 3:08 pm
Location: Italy

Re: single acting cylinder

Postby Julio Jerez » Thu Nov 15, 2018 11:22 am

Oh thanks, I was wondering why wasn't working.
so now is cool and only thing pending is exposing the actuator dof force or torque?

I will do the low lever today, then the plugin.
Julio Jerez
Moderator
Moderator
 
Posts: 11045
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: single acting cylinder

Postby blackbird_dream » Thu Nov 15, 2018 11:29 am

yes it's cool.
User avatar
blackbird_dream
 
Posts: 279
Joined: Wed Jun 07, 2006 3:08 pm
Location: Italy

Re: single acting cylinder

Postby Julio Jerez » Thu Nov 15, 2018 2:37 pm

ok I added the function
Code: Select all
class dCustomSliderActuator: public dCustomSlider
{
   public:
...
...
   CUSTOM_JOINTS_API dFloat GetForce() const;
   CUSTOM_JOINTS_API dFloat GetMaxForce() const;
   CUSTOM_JOINTS_API dFloat GetMinForce() const;
...


remember the force is the value after the solve update, so it will always be one update behind.
but since forces are persistent and need time to act they do no chnge much for update to update, it sould this is fine.
It should be very accurate also, down to the ounces or milligrams. you should be able to compared to real life values. Is not is the plugin yet but that's just boiler plate.
tell me if you need the torque on the hinge as well.
Julio Jerez
Moderator
Moderator
 
Posts: 11045
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: single acting cylinder

Postby blackbird_dream » Fri Nov 16, 2018 3:24 am

If you have some time yes would be of interest thks.
great
Your engine is really cool
User avatar
blackbird_dream
 
Posts: 279
Joined: Wed Jun 07, 2006 3:08 pm
Location: Italy

Re: single acting cylinder

Postby Julio Jerez » Fri Nov 16, 2018 8:07 am

al right it is now exposed to the plugin, I do not knwo how to make read only values in the unity editor, I added it like this
Code: Select all
public class NewtonSliderActuator : NewtonJoint
{
    public override void InitJoint()
    {
        NewtonBody child = GetComponent<NewtonBody>();
        dMatrix matrix = Utils.ToMatrix(m_posit, Quaternion.Euler(m_rotation));
        IntPtr otherBody = (m_otherBody != null) ? m_otherBody.GetBody().GetBody() : new IntPtr(0);
        m_joint = new dNewtonJointSliderActuator(matrix, child.GetBody().GetBody(), otherBody);

        Speed = m_speed;
        MaxForce = m_maxForce;
        MinForce = m_minForce;
        TargetPosition = m_targetPosition;
    }

    public float Force
    {
        get
        {
            float force = 0;
            if (m_joint != null)
            {
                dNewtonJointSliderActuator joint = (dNewtonJointSliderActuator)m_joint;
                force = joint.GetForce();
            }
            return force;
        }

...
...
    }


I am not sure if it required as a member in .cs class.
This is a read only value, in general an app does not need to read that kind value every time, your case is special.

Unity has a very high overhead cost for making function calls to cpp wrapper, Sweenie had to do lots of special .cs tricks to minimize the impact.
so maybe we do not even want that in the editor anyway, just as an unlisted member class function that can be called.
anyway you can test it now.
Julio Jerez
Moderator
Moderator
 
Posts: 11045
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: single acting cylinder

Postby Sweenie » Fri Nov 16, 2018 9:28 am

That looks fine to me and i agree that a readonly property should be enough, just like you did.
Sweenie
 
Posts: 490
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: single acting cylinder

Postby blackbird_dream » Fri Nov 16, 2018 9:49 am

great
User avatar
blackbird_dream
 
Posts: 279
Joined: Wed Jun 07, 2006 3:08 pm
Location: Italy

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest