public bool AddDrawCommand(GlobalGeometryPartBlockNew part, Bucket sourceBucket, InstanceInfo instanceInfo) { var primitiveType = part.GlobalGeometryPartNewFlags.HasFlag( GlobalGeometryPartBlockNew.Flags.OverrideTriangleList) ? PrimitiveType.Triangles : PrimitiveType.TriangleStrip; if (primitiveType != PrimitiveType) { return(false); } if (sourceBucket != SourceBucket) { return(false); } var locations = sourceBucket[part]; var command = new DrawIndirectCmd( part.StripLength, instanceInfo.Count, // Divide by two because this is an offset and we need an index locations.IndexBaseOffset / sizeof(ushort) + part.StripStartIndex, locations.VertexBaseOffset, instanceInfo.BaseInstance); CommandBuffers.Add(command); return(true); }
public void AssignShader(GlobalGeometryPartBlockNew part, CacheKey cacheKey, TagIdent shaderIdent) { var glocalKey = new TagGlobalKey(cacheKey, shaderIdent); // Does this work now? _shaderDictionary[part] = glocalKey; }
/// <summary> /// Creates an instance object for the given part /// </summary> /// <param name="part">The part to be instanced</param> /// <param name="instance">The instance data</param> /// <remarks> /// i. Every part many be instanced zero or many times /// ii. Instances should refer to a collection of parts /// iii. Instance data is linked to a single instance /// </remarks> public void CreateInstance(GlobalGeometryPartBlockNew part, IH2ObjectInstance instance, bool supportsPermutations) { // 1. Check if the part is already in dictionary and initialize it into the dictionary if not HashSet <InstanceKey> instances; if (!PartInstances.TryGetValue(part, out instances)) { // Initialize a collection of instance identifiers instances = new HashSet <InstanceKey>( ); PartInstances.Add(part, instances); } // 2. Check to see if this instance has already been added InstanceKey key; if (!InstanceKeys.TryGetValue(instance, out key)) { // (a) Create a key for the new instance and (b) link the key with the instance key = CreateInstanceKey( ); InstanceKeys.Add(instance, key); // (c) Link the key with the intance data InstanceData.Add(key, new InstanceData(instance, supportsPermutations)); } // 3. Check to see if the part is already linked with the instance instances.Add(key); }
public void AddInstances(GlobalGeometryPartBlockNew part, IEnumerable <Matrix4> instanceWorldMatrices) { if (!Instances.ContainsKey(part)) { Instances[part] = new List <Matrix4>(instanceWorldMatrices); return; } Instances[part].AddRange(instanceWorldMatrices); }
public Bucket GetBucketResource(GlobalGeometryPartBlockNew part, out int indexBaseOffset, out int vertexBaseOffset) { var bucket = _buckets.Single(u => u.Contains(part)); var locations = bucket.GetBufferLocation(part); indexBaseOffset = locations.IndexBaseOffset; vertexBaseOffset = locations.VertexBaseOffset; return(bucket); }
public InstanceData[] GetInstancesOf(GlobalGeometryPartBlockNew part) { var instanceDatum = new InstanceData[PartInstances[part].Count]; int index = 0; foreach (var instanceKey in PartInstances[part]) { instanceDatum[index++] = InstanceData[instanceKey]; } return(instanceDatum); }
public bool RemoveInstance(GlobalGeometryPartBlockNew part, dynamic instance) { if (!PartInstances.ContainsKey(part)) { return(false); } if (!InstanceKeys.ContainsKey(instance)) { return(false); } var key = InstanceKeys[instance]; if (!PartInstances[part].Contains(key)) { return(false); } PartInstances[part].Remove(key); return(true); }
public InstanceInfo this[GlobalGeometryPartBlockNew key] { get { return(InstanceInfos[key]); } }
public void RemoveInstance(GlobalGeometryPartBlockNew part, dynamic instance) { InstanceManager.RemoveInstance(part, instance); }
/// <summary> /// Creates an instance object for the given part /// </summary> /// <param name="part">The part to be instanced</param> /// <param name="instance">The instance data</param> public void CreateInstance(GlobalGeometryPartBlockNew part, IH2ObjectInstance instance, bool supportsPermutations) { InstanceManager.CreateInstance(part, instance, supportsPermutations); }
public Bucket GetBucketResource(GlobalGeometryPartBlockNew part) { return(_buckets.Single(u => u.Contains(part))); }
public int GetInstanceCount(GlobalGeometryPartBlockNew part) { return(PartInstances[part].Count); }
public PatchData(GlobalGeometryPartBlockNew part, InstanceData data) { Part = part; Data = data; }