Пример #1
0
        public void Execute()
        {
            if (!customSymbols.hasIdentifiers)
            {
                maxIdentityId[0] = 0;
                return;
            }

            for (int symbolIndex = 0; symbolIndex < targetData.Length; symbolIndex++)
            {
                var symbol = targetData[symbolIndex];
                if (symbol == customSymbols.identifier)
                {
                    uint currentId = (uint)targetData.parameters[symbolIndex, 1];
                    if (currentId == 0)
                    {
                        lastMaxIdReached++;
                        currentId = lastMaxIdReached;
                        targetData.parameters[symbolIndex, 1] = (float)currentId;
                        targetData.parameters[symbolIndex, 2] = uniquePlantId;
                    }
                    var updatedOrganId = new UIntFloatColor32(currentId + originOfUniqueIndexes);
                    targetData.parameters[symbolIndex, 0] = updatedOrganId.FloatValue;
                }
            }
            maxIdentityId[0] = lastMaxIdReached;
        }
        public void Execute()
        {
            var branchIdentity = new BranchIdentity
            {
                identity        = 0,
                appliedSunlight = false
            };

            for (int symbolIndex = 0; symbolIndex < symbols.Length; symbolIndex++)
            {
                var symbol = symbols[symbolIndex];
                if (symbol == customSymbols.identifier)
                {
                    var identityBits = new UIntFloatColor32(symbols.parameters[symbolIndex, 0]);
                    branchIdentity = new BranchIdentity(identityBits.UIntValue);
                }
                else if (symbol == customSymbols.branchOpenSymbol)
                {
                    lastIdentityStack.Push(branchIdentity);
                }
                else if (symbol == customSymbols.branchCloseSymbol)
                {
                    branchIdentity = lastIdentityStack.Pop();
                }
                else if (symbol == customSymbols.sunlightSymbol)
                {
                    if (branchIdentity.identity <= 0)
                    {
                        continue;
                    }
                    uint pixelCount = 0;
                    if (organCountsByIndex.Length > branchIdentity.identity)
                    {
                        pixelCount = organCountsByIndex[(int)branchIdentity.identity];
                    }
                    var sunlightAmount = sunlightPerPixel * pixelCount;
                    symbols.parameters[symbolIndex, 0] = sunlightAmount;
                    branchIdentity.appliedSunlight     = true;
                }
            }
        }