Exemplo n.º 1
0
    public void TestInitShutdownLibrary()
    {
        Flex.Library lib         = Flex.Init(Flex.FLEX_VERSION, ErrorCallback);
        int          flexVersion = Flex.GetVersion();

        Assert.AreEqual(Flex.FLEX_VERSION, flexVersion);
        Flex.Shutdown(lib);
    }
Exemplo n.º 2
0
    public void TestGetLibraryVersion()
    {
        Flex.Library lib = Flex.Init();

        int flexVersion = Flex.GetVersion();

        Assert.AreEqual(Flex.FLEX_VERSION, flexVersion);

        Flex.Shutdown(lib);
    }
Exemplo n.º 3
0
        void Start()
        {
            if (m_cntr == null)
            {
                m_cntr = GetComponent <FlexContainer>();
            }

            if (m_diffuseParticles == null)
            {
                m_diffuseParticles = GetComponent <FlexDiffuseParticles>();
            }

            if (m_parameters == null)
            {
                m_parameters = GetComponent <FlexParameters>();
            }

            if (m_colliders == null)
            {
                m_colliders = GetComponent <FlexColliders>();
            }

            m_errorCallback = new Flex.ErrorCallback(this.ErrorCallback);

            m_timers = new Flex.Timers();

            Flex.Error flexErr = Flex.Init(100, m_errorCallback, -1);

            Debug.Log("NVidia FleX v" + Flex.GetVersion());
            if (flexErr != Flex.Error.eFlexErrorNone)
            {
                Debug.LogError("FlexInit: " + flexErr);
            }

            if (m_diffuseParticles)
            {
                m_solverPtr = Flex.CreateSolver(m_cntr.m_maxParticlesCount, m_diffuseParticles.m_maxDiffuseParticlesCount, m_maxNeighboursCount);
            }
            else
            {
                m_solverPtr = Flex.CreateSolver(m_cntr.m_maxParticlesCount, 0, m_maxNeighboursCount);
            }

            m_parameters.GetParams(ref m_params);
            Flex.SetParams(m_solverPtr, ref m_params);

            m_cntr.UpdateContainer();

            m_processors = FindObjectsOfType <FlexProcessor>();
            foreach (FlexProcessor fp in m_processors)
            {
                fp.FlexStart(this, m_cntr, m_parameters);
            }

            PushParticlesToGPU(m_solverPtr, m_cntr, Flex.Memory.eFlexMemoryHost);

            PushConstraintsToGPU(m_solverPtr, m_cntr, Flex.Memory.eFlexMemoryHost);

            if (m_colliders)
            {
                m_colliders.ProcessColliders(m_solverPtr, Flex.Memory.eFlexMemoryHost);
            }

            //Flex.SetShapes(m_solverPtr, m_cnt.shapeGeometry, shapeGeometry.Length, shapeAabbMin, shapeAabbMax, shapeStarts, shapePositions, shapeRotations,
            //          shapePrevPositions, shapePrevRotations, shapeFlags, shapeStarts.Length, Flex.Memory.eFlexMemoryHost);
        }