Пример #1
0
    public bool refresh(bool reload_asset, HAPI_ObjectInfo object_info)
    {
        bool needs_recook = false;

        if (reload_asset)
        {
            for (int i = 0; i < myGeos.Count; ++i)
            {
                if (myGeos[i])
                {
                    HoudiniAssetUtility.destroyGameObject(myGeos[i]);
                }
            }
            myGeos.Clear();
        }

        if (reload_asset || object_info.haveGeosChanged)
        {
            // Get the GeoInfos of the display geo node
            HAPI_GeoInfo display_geo_info = HoudiniHost.getDisplayGeoInfo(prObjectId);
            int          GeoCount         = object_info.geoCount = 1;

            // Add new geos as needed.
            while (myGeos.Count < GeoCount)
            {
                myGeos.Add(createGeo(display_geo_info.nodeId));
            }

            int node_id = object_info.nodeId;
            if (prAsset.prNodeInfo.type == HAPI_NodeType.HAPI_NODETYPE_SOP)
            {
                node_id = display_geo_info.nodeId;
            }

            // Look for editable nodes inside the network/the object
            const bool recursive         = true;
            int[]      editable_networks = HoudiniHost.getChildNodeList(
                node_id,
                (int)HAPI_NodeType.HAPI_NODETYPE_SOP,
                (int)HAPI_NodeFlags.HAPI_NODEFLAGS_EDITABLE,
                recursive);

            // Add the editable nodes to it
            for (int n = 0; n < editable_networks.Length; n++)
            {
                // The editable node has to be cooked first
                HoudiniHost.cookNode(editable_networks[n]);

                HAPI_GeoInfo editGeoInfo = HoudiniHost.getGeoInfo(editable_networks[n]);
                myGeos.Add(createGeo(editGeoInfo.nodeId));
                GeoCount++;
            }

            // Remove stale geos.
            while (myGeos.Count > GeoCount)
            {
                HoudiniAssetUtility.destroyGameObject(myGeos[GeoCount]);
                myGeos.RemoveAt(GeoCount);
            }

            // Refresh all geos.
            for (int i = 0; i < myGeos.Count; ++i)
            {
                needs_recook |= myGeos[i].GetComponent <HoudiniGeoControl>().refresh(reload_asset);
            }
        }

        return(needs_recook);
    }