public void Add(KAnimConverter.IAnimConverter controller)
    {
        int layer = controller.GetLayer();

        if (layer != key.layer)
        {
            Debug.LogError("Registering with wrong batch set (layer) " + controller.GetName());
        }
        HashedString batchGroupID = controller.GetBatchGroupID(false);

        if (!(batchGroupID == key.groupID))
        {
            Debug.LogError("Registering with wrong batch set (groupID) " + controller.GetName());
        }
        KAnimBatchGroup.MaterialType materialType = controller.GetMaterialType();
        for (int i = 0; i < batches.Count; i++)
        {
            if (batches[i].size < group.maxGroupSize && batches[i].materialType == materialType)
            {
                if (batches[i].Register(controller))
                {
                    SetDirty();
                }
                return;
            }
        }
        KAnimBatch kAnimBatch = new KAnimBatch(group, layer, controller.GetZ(), materialType);

        kAnimBatch.Init();
        AddBatch(kAnimBatch);
        kAnimBatch.Register(controller);
    }
 private BatchKey(KAnimConverter.IAnimConverter controller)
 {
     _layer        = controller.GetLayer();
     _groupID      = controller.GetBatchGroupID(false);
     _materialType = controller.GetMaterialType();
     _z            = controller.GetZ();
     _idx          = KAnimBatchManager.ControllerToChunkXY(controller);
     _hash         = 0;
 }
Example #3
0
 public KAnimBatch(KAnimBatchGroup group, int layer, float z, KAnimBatchGroup.MaterialType material_type)
 {
     id                      = nextBatchId++;
     active                  = true;
     this.group              = group;
     this.layer              = layer;
     batchGroup              = group.batchID;
     materialType            = material_type;
     position                = new Vector3(0f, 0f, z);
     symbolInstanceSlots     = new SymbolInstanceSlot[group.maxGroupSize];
     symbolOverrideInfoSlots = new SymbolOverrideInfoSlot[group.maxGroupSize];
 }
Example #4
0
 /// <summary>
 /// Applied after the constructor runs.
 /// </summary>
 internal static void Postfix(KAnimBatch __instance, KAnimBatchGroup group,
                              int layer, MaterialType material_type)
 {
     if (group != null && material_type != MaterialType.UI)
     {
         int id = __instance.id;
         // Destroy the existing renderer if it exists
         if (visualizers.TryGetValue(id, out KAnimMeshRenderer renderer) &&
             renderer != null)
         {
             renderer.DestroyRenderer();
         }
         visualizers[id] = KAnimMeshRenderer.Create(group.mesh, group.
                                                    GetMaterial(material_type), layer, id);
     }
 }