/// <summary> /// /// </summary> public BaseField() { m_UpdateValues = new UpdateValue[this.ObjectUpdateFieldCount]; m_PrivateUpdateMask = new UpdateMask( this.ObjectUpdateFieldCount ); m_PublicUpdateMask = new UpdateMask( this.ObjectUpdateFieldCount ); this.Type = ObjectTypes.Object; this.ScaleX = 1.0f; }
/// <summary> /// /// </summary> /// <returns></returns> internal UpdateMask ResumePrivateUpdateMask() { UpdateMask privateUpdateMask = new UpdateMask( this.ObjectUpdateFieldCount ); UpdateMask returnUpdateMask = m_PrivateUpdateMask; // 快速交换,避免多线程问题 m_PrivateUpdateMask = privateUpdateMask; return returnUpdateMask; }
/// <summary> /// /// </summary> /// <param name="mask"></param> /// <param name="lowestValue"></param> /// <param name="highestValue"></param> public static void ModifyUpdateMask( UpdateMask updateMask, int iLowestValue, int iHighestValue ) { int iBlockCount = ( iHighestValue + 31 ) >> 5; int iStartingBlock = ( iLowestValue ) >> 5; for ( int iIndex = iStartingBlock; iIndex < iBlockCount; iIndex++ ) updateMask.Blocks[iIndex] &= m_PlayerVisibility[iIndex]; }
/// <summary> /// Modifies the specified UpdateMask to filter out all the bits not needed for other players /// </summary> /// <param name="mask">The UpdateMask to filter</param> public static void ModifyUpdateMask( ref UpdateMask updateMask ) { for ( int iIndex = 0; iIndex < updateMask.BlockCount; iIndex++ ) updateMask.Blocks[iIndex] &= m_PlayerVisibility[iIndex]; }
public static GameObject Import( USD.NET.Scene scene, GameObject rootObj, Dictionary <SdfPath, GameObject> objectMap, UpdateMask mask, out List <string> warnings, List <string> pathsToUpdate = null) { // TODO: generalize this to avoid having to dig down into USD for sparse reads. TfToken brushToken = new pxr.TfToken("brush"); TfToken faceVertexIndicesToken = new pxr.TfToken("faceVertexIndices"); warnings = new List <string>(); // Would be nice to find a way to kick this off automatically. // Redundant calls are ignored. if (!InitUsd.Initialize()) { return(null); } // PLAN: Process any UsdStage either constructing or updating GameObjects as needed. // This should include analysis of the time samples to see what attributes are // actually varying so they are updated minimally. UsdPrimVector prims = null; if (pathsToUpdate == null) { prims = scene.Stage.GetAllPrims(); } else { prims = new UsdPrimVector(); foreach (var path in pathsToUpdate) { prims.Add(scene.Stage.GetPrimAtPath(new pxr.SdfPath(path))); } } for (int p = 0; p < prims.Count; p++) { // TODO: prims[p] generates garbage. UsdPrim usdPrim = prims[p]; UsdGeomMesh usdMesh = new UsdGeomMesh(usdPrim); if (!usdMesh) { continue; } ExportUsd.BrushSample sample = new ExportUsd.BrushSample(); if (mask == UpdateMask.All) { scene.Read(usdPrim.GetPath(), sample); } else { // TODO: Generalize this as a reusable mechanism for sparse reads. if (mask == UpdateMask.Topology) { sample.brush = new Guid((string)usdPrim.GetCustomDataByKey(brushToken)); var fv = usdPrim.GetAttribute(faceVertexIndicesToken).Get(scene.Time); sample.faceVertexIndices = USD.NET.IntrinsicTypeConverter.FromVtArray((VtIntArray)fv); } else { throw new NotImplementedException(); } } GameObject strokeObj; Mesh unityMesh; // // Construct the GameObject if needed. // if (!objectMap.TryGetValue(usdPrim.GetPath(), out strokeObj)) { // On first import, we need to pull in all the data, regardless of what was requested. mask = UpdateMask.All; BrushDescriptor brush = BrushCatalog.m_Instance.GetBrush(sample.brush); if (brush == null) { Debug.LogWarningFormat("Invalid brush GUID at path: <{0}> guid: {1}", usdPrim.GetPath(), sample.brush); continue; } strokeObj = UnityEngine.Object.Instantiate(brush.m_BrushPrefab); // Register the Prim/Object mapping. objectMap.Add(usdPrim.GetPath(), strokeObj); // Init the game object. strokeObj.transform.parent = rootObj.transform; strokeObj.GetComponent <MeshRenderer>().material = brush.Material; strokeObj.GetComponent <MeshFilter>().sharedMesh = new Mesh(); strokeObj.AddComponent <BoxCollider>(); unityMesh = strokeObj.GetComponent <MeshFilter>().sharedMesh; } else { unityMesh = strokeObj.GetComponent <MeshFilter>().sharedMesh; } // // Points // Note that points must come first, before all other mesh data. // if ((mask & UpdateMask.Points) == UpdateMask.Points) { unityMesh.vertices = sample.points; } // // Bounds // if ((mask & UpdateMask.Bounds) == UpdateMask.Bounds) { var bc = strokeObj.GetComponent <BoxCollider>(); bc.center = sample.extent.center; bc.size = sample.extent.size; unityMesh.bounds = bc.bounds; } // // Topology // if ((mask & UpdateMask.Topology) == UpdateMask.Topology) { unityMesh.triangles = sample.faceVertexIndices; } // // Normals // if ((mask & UpdateMask.Normals) == UpdateMask.Normals) { unityMesh.normals = sample.normals; } // // Color & Opacity // if ((mask & UpdateMask.Colors) == UpdateMask.Colors && sample.colors != null) { unityMesh.colors = sample.colors; } // // Tangents // if ((mask & UpdateMask.Tangents) == UpdateMask.Tangents && sample.tangents != null) { unityMesh.tangents = sample.tangents; } // // UVs // if ((mask & UpdateMask.UVs) == UpdateMask.UVs) { SetUv(unityMesh, 0, sample.uv); SetUv(unityMesh, 1, sample.uv2); SetUv(unityMesh, 2, sample.uv3); SetUv(unityMesh, 3, sample.uv4); } } // For each prim return(rootObj); }
public BaseUpdateData(int changeMask) { _changesMask = new UpdateMask(changeMask); }
public BaseUpdateData(int blockBit, TypeId bit, int changeMask) { _blockBit = blockBit; Bit = (int)bit; _changesMask = new UpdateMask(changeMask); }