/// <inheritdoc />
        public override void PrepareVertexLayout(ParticlePoolFieldsList fieldsList)
        {
            base.PrepareVertexLayout(fieldsList);

            // Probe if the particles have a color field and if we need to support it
            var colorField = fieldsList.GetField(ParticleFields.Color);
            if (colorField.IsValid() != HasColorField)
            {
                HasVertexLayoutChanged = true;
                HasColorField = colorField.IsValid();
            }
        }
예제 #2
0
        /// <inheritdoc />
        public override void PrepareVertexLayout(ParticlePoolFieldsList fieldsList)
        {
            base.PrepareVertexLayout(fieldsList);

            // Probe if the particles have a color field and if we need to support it
            var colorField = fieldsList.GetField(ParticleFields.Color);

            if (colorField.IsValid() != HasColorField)
            {
                HasVertexLayoutChanged = true;
                HasColorField          = colorField.IsValid();
            }
        }
예제 #3
0
        /// <summary>
        /// <see cref="PrepareForDraw"/> prepares and updates the Material, ShapeBuilder and VertexBuilder if necessary
        /// </summary>
        public void PrepareForDraw(out bool vertexBufferHasChanged, out int vertexSize, out int vertexCount)
        {
            var fieldsList = new ParticlePoolFieldsList(pool);

            // User changes to materials might cause vertex layout change
            Material.PrepareVertexLayout(fieldsList);

            // User changes to shape builders might cause vertex layout change
            ShapeBuilder.PrepareVertexLayout(fieldsList);

            // Recalculate the required vertex count and stride
            VertexBuilder.SetRequiredQuads(ShapeBuilder.QuadsPerParticle, pool.LivingParticles, pool.ParticleCapacity);

            vertexBufferHasChanged = (Material.HasVertexLayoutChanged || ShapeBuilder.VertexLayoutHasChanged || VertexBuilder.IsBufferDirty);

            // Update the vertex builder and the vertex layout if needed
            if (vertexBufferHasChanged)
            {
                VertexBuilder.ResetVertexElementList();

                Material.UpdateVertexBuilder(VertexBuilder);

                ShapeBuilder.UpdateVertexBuilder(VertexBuilder);

                VertexBuilder.UpdateVertexLayout();
            }

            vertexSize = VertexBuilder.VertexDeclaration.CalculateSize();
            vertexCount = VertexBuilder.VertexCount;
            VertexBuilder.SetDirty(false);
        }
예제 #4
0
 /// <summary>
 /// Check if ParticleVertexElements should be changed and set HasVertexLayoutChanged = true; if they do
 /// </summary>
 /// <param name="fieldsList">A container for the <see cref="ParticlePool"/> which can poll if a certain field exists as an attribute</param>
 public virtual void PrepareVertexLayout(ParticlePoolFieldsList fieldsList)
 {
     // Check if ParticleVertexElements should be changed and set HasVertexLayoutChanged = true; if they do
 }
예제 #5
0
 /// <summary>
 /// Prepares the material for drawing the current frame with the current <see cref="ParticleVertexBuilder"/> and <see cref="ParticleSorter"/>
 /// </summary>
 /// <param name="fieldsList">A container for the <see cref="ParticlePool"/> which can poll if a certain field exists as an attribute</param>
 public virtual void PrepareVertexLayout(ParticlePoolFieldsList fieldsList)
 {
 }
예제 #6
0
 /// <summary>
 /// Check if ParticleVertexElements should be changed and set HasVertexLayoutChanged = true; if they do
 /// </summary>
 /// <param name="fieldsList">A container for the <see cref="ParticlePool"/> which can poll if a certain field exists as an attribute</param>
 public virtual void PrepareVertexLayout(ParticlePoolFieldsList fieldsList)
 {
     // Check if ParticleVertexElements should be changed and set HasVertexLayoutChanged = true; if they do
 }
예제 #7
0
 /// <summary>
 /// Prepares the material for drawing the current frame with the current <see cref="ParticleVertexBuilder"/> and <see cref="ParticleSorter"/>
 /// </summary>
 /// <param name="fieldsList">A container for the <see cref="ParticlePool"/> which can poll if a certain field exists as an attribute</param>
 public virtual void PrepareVertexLayout(ParticlePoolFieldsList fieldsList)
 {
 }