Ejemplo n.º 1
0
        /// <inheritdoc />
        public PointLight()
        {
            _range   = 8;
            _falloff = 4;

            Lighting.AddPointLight(this);

            ParentChanged.Event += OnParentChanged;

            /*
             * _updatePointLightJob = new RenderJob("UpdatePointLightData", context =>
             * {
             *      var lightIndex = LightIndex;
             *      DataStream stream;
             *      var buffer = Renderer.PointLightBuffer;
             *      if (buffer == null)
             *              return;
             *      context.MapSubresource(buffer, MapMode.Write, 0, out stream);
             *      stream.Position = PointLightData.Stride * lightIndex;
             *      stream.Write(new PointLightData
             *      {
             *              Colour = (Color3)Colour,
             *              Falloff = _falloff,
             *              Range = _range,
             *              Position = _parentPart.CFrame.p
             *      });
             *      context.UnmapSubresource(Renderer.PointLightBuffer, 0);
             * });
             */
        }
Ejemplo n.º 2
0
        private void OnParentChanged(Instance parent)
        {
            var part = parent as Part;

            if (_parentPart != null)
            {
                _parentPart.Moved.Event -= OnParentMoved;
            }

            if (part == null)
            {
                Lighting.RemovePointLight(this);
            }
            else
            {
                Lighting.AddPointLight(this);
                part.Moved.Event += OnParentMoved;
            }

            _parentPart = part;
        }