ChronoEngine_SwAddin.SWTaskpaneHost.PythonTraverseComponent_for_countingmassbodies C# (CSharp) Method

PythonTraverseComponent_for_countingmassbodies() public method

public PythonTraverseComponent_for_countingmassbodies ( Component2 swComp, int &valid_bodies ) : void
swComp Component2
valid_bodies int
return void
        public void PythonTraverseComponent_for_countingmassbodies(Component2 swComp, ref int valid_bodies)
        {
            // Add bodies of this component to the list
            object[] bodies;
            object bodyInfo;
            bodies = (object[])swComp.GetBodies3((int)swBodyType_e.swAllBodies, out bodyInfo);

            if (bodies != null)
            {
                // note: some bodies might be collision shapes and must not enter the mass computation:
                for (int ib = 0; ib < bodies.Length; ib++)
                {
                    Body2 abody = (Body2)bodies[ib];
                    if (!(abody.Name.StartsWith("COLL.")))
                    {
                        valid_bodies += 1;
                    }
                }
            }

            // Recursive scan of subcomponents

            Component2 swChildComp;
            object[] vChildComp = (object[])swComp.GetChildren();
            for (long i = 0; i < vChildComp.Length; i++)
            {
                swChildComp = (Component2)vChildComp[i];
                PythonTraverseComponent_for_countingmassbodies(swChildComp, ref valid_bodies);
            }
        }