Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scaling Softbody / Solver Updates
#3
Hi Jose,

thanks for your quick response!

I'm (now) aware of that. Maybe I didn't understand the principle of the simulation "domain" right, but I think, upon further reading, I now do.
What's still confusing me is that an ObiActor will not act the same as a regular child GameObject. You pointed out the TransformPoint etc. methods (which is greatly appreciated), but to me it's still a myracle how i could compensate the change in the simulation since i can't set the local nor world coordinates of the ObiActor (ObiSoftbody in my case) directly since... well it's simulated Guiño

I made some small scripts to test this "domain behaviour" and it's clearly not the same with regular unity objects. Pls. see demonstration here: behaviour demo

The scripts are mainly the same, I just grab transforms from different components.
For ObiSolver:
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Obi;

[RequireComponent(typeof(ObiSolver))]
public class Test_ObiSolverScaler : MonoBehaviour
{
    [Range(0.1f, 5f)]
    public float scale = 2.0f;

    public ObiActor actor;

    private ObiSolver solver;

    private void Awake()
    {
        solver = GetComponent<ObiSolver>();
    }

    // Start is called before the first frame update
    void Start()
    {
           
    }

    // Update is called once per frame
    void Update()
    {
        Vector3 actorPos = actor.transform.position;

        //Debug.Log("ActorPosWorld = " + actorPosWorld); 

        Vector3 actualScale = transform.localScale;

        actualScale.x = scale;
        actualScale.y = scale;
        actualScale.z = scale;

        transform.localScale = actualScale;

        actor.transform.localPosition = transform.InverseTransformPoint(actorPos);
    }
}



For TestSolver (with simple parent/child relation):

Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Obi;


public class Test_DomainScale : MonoBehaviour
{
    [Range(0.1f, 5f)]
    public float scale = 2.0f;

    public Transform actor;

    private Transform solver;

    private void Awake()
    {
        solver = GetComponent<Transform>();
    }

    // Start is called before the first frame update
    void Start()
    {
           
    }

    // Update is called once per frame
    void Update()
    {
        Vector3 actorPos = actor.transform.position;

        //Debug.Log("ActorPosWorld = " + actorPosWorld); 

        Vector3 actualScale = transform.localScale;

        actualScale.x = scale;
        actualScale.y = scale;
        actualScale.z = scale;

        transform.localScale = actualScale;

        actor.transform.localPosition = transform.InverseTransformPoint(actorPos);
    }
}


I'm just in the dark and really appreciate any help from you guys. Do I really need to update every particle position by hand? (I don't think that's gonna be performant..)
Or is there another way to scale the solver and therefore its simulated bodies and keep them running without positional changes?

Many thanks Sonrisa a fellow, maybe not so smart dev..

Michael Menzi
Reply


Messages In This Thread
Scaling Softbody / Solver Updates - by nakoustix - 21-11-2022, 10:13 PM
RE: Scaling Softbody / Solver Updates - by nakoustix - 22-11-2022, 09:08 PM