Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
   Copyright (c) 2017 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software
   and associated documentation files (the "Software"), to deal in the Software
   without restriction,
   including without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
   PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
   IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef _PARTICLE_DATA_H_
#define _PARTICLE_DATA_H_

#include "Graphs/Headers/SceneNode.h"

namespace Divide {

/// Container to store data for a given set of particles
class ParticleData {
   public:
    static const U32 g_threadPartitionSize = 256;

    enum class Properties : U32 {
        PROPERTIES_POS = toBit(1),
        PROPERTIES_VEL = toBit(2),
        PROPERTIES_ACC = toBit(3),
        PROPERTIES_COLOR = toBit(4),
        PROPERTIES_COLOR_TRANS = toBit(5),
        COUNT
    };
    /// helper array used for sorting
    vectorImplBest<std::pair<U32, F32>> _indices;
    vectorImplBest<vec4<F32>> _renderingPositions;
    vectorImplBest<UColour>   _renderingColours;
    /// x,y,z = position; w = size
    vectorImplBest<vec4<F32>> _position;
    /// x,y,z = _velocity; w = angle;
    vectorImplBest<vec4<F32>> _velocity;
    /// x,y,z = _acceleration; w = weight;
    vectorImplBest<vec4<F32>> _acceleration;
    /// x = time; y = interpolation; z = 1 / time;  w = distance to camera sq;
    vectorImplBest<vec4<F32>> _misc;
    /// r,g,b,a = colour and transparency
    vectorImplBest<FColour> _colour;
    /// r,g,b,a = colour and transparency
    vectorImplBest<FColour> _startColour;
    /// r,g,b,a = colour and transparency
    vectorImplBest<FColour> _endColour;
    /// Location of the texture file. Leave blank for colour only
    stringImpl _textureFileName;


    void setParticleGeometry(const vectorImpl<vec3<F32>>& particleGeometryVertices,
                             const vectorImpl<U32>& particleGeometryIndices,
                             PrimitiveType particleGeometryType);

    void setBillboarded(const bool state);

    inline PrimitiveType particleGeometryType() const {
        return _particleGeometryType;
    }

    inline const vectorImpl<vec3<F32>>& particleGeometryVertices() const {
        return _particleGeometryVertices;
    }

    inline const vectorImpl<U32>& particleGeometryIndices() const {
        return _particleGeometryIndices;
    }

    inline bool isBillboarded() const {
        return _isBillboarded;
    }
   public:
    explicit ParticleData(GFXDevice& context, U32 particleCount, U32 optionsMask);
    ~ParticleData();

    void generateParticles(U32 particleCount, U32 optionsMask);
    void kill(U32 index);
    void wake(U32 index);
    void swapData(U32 indexA, U32 indexB);

    inline U32 aliveCount() const { return _aliveCount; }
    inline U32 totalCount() const { return _totalCount; }
    
    /// Sort ALIVE particles only
    void sort(bool invalidateCache);

   protected:
    U32 _totalCount;
    U32 _aliveCount;
    U32 _optionsMask;

    bool _isBillboarded;
    vectorImpl<vec3<F32>> _particleGeometryVertices;
    vectorImpl<U32> _particleGeometryIndices;
    PrimitiveType _particleGeometryType;

    GFXDevice& _context;
};

};  // namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/Dynamics/Entities/Particles/Headers/ParticleData.h

Diff revisions: vs.
Revision Author Commited Message
1004 Diff Diff IonutCava picture IonutCava Wed 20 Dec, 2017 17:16:32 +0000

[Ionut]
- More GUI cleanup (added multiple GUIButton events)
- Typedef vec4<U8> and vec4<F32> to UColour and FColour respectively for easier to read code.

909 Diff Diff IonutCava picture IonutCava Thu 29 Jun, 2017 23:57:18 +0000

[Ionut]
- Rework RenderTarget class
— RTAttachment now deal with textures directly
— RT size needs to be specified upfront
- Application class is no longer a Singleton but passed around in the PlatformContext

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

833 Diff Diff IonutCava picture IonutCava Thu 26 Jan, 2017 22:04:33 +0000

[IonutCava]
- Fix most build errors. Divide-Server does not build for now.

788 Diff Diff IonutCava picture IonutCava Fri 21 Oct, 2016 16:11:37 +0000

[IonutCava]
- Added support for the Arena Allocator by Mamasha Knows (http://www.codeproject.com/Articles/44850/Arena-Allocator-DTOR-and-Embedded-Preallocated-Buf)
— Used for GFX Related objects: Textures, shaders, etc

738 Diff Diff IonutCava picture IonutCava Fri 24 Jun, 2016 16:06:04 +0000

[IonutCava]
- Performance improvement: Create linear list of ordered SGNs for update and split update step in two to allow parallel tasks in the first step to finish before moving to second step
- Performance improvement: Remove glFlush calls for lock manager. Drivers should be up to the task now
- Performance improvement: Re-enabled round robin buffer system for ParticleEmitter

737 Diff Diff IonutCava picture IonutCava Thu 23 Jun, 2016 16:20:05 +0000

[IonutCava]
- Improved GenericVertexData structure (separate buffer data from attribute data entirely)
- Added a VAO pool for OpenGL so that all requested VAOs are allocated on the main thread
- Added a mainThreadTask system to queue a task to run on the main thread and optionally wait for it to complete
- Added the option to specify generic geometry for the particle system with an optional index buffer

721 Diff Diff IonutCava picture IonutCava Wed 08 Jun, 2016 15:47:49 +0000

[IonutCava]
- Spelling: change all references from our code of “color” to the PROPER British version of “colour” because it sounds 100x better

671 Diff Diff IonutCava picture IonutCava Fri 08 Apr, 2016 16:26:49 +0000

[Ionut]
- Custom memory allocation system part 1:
— Add http://www.codeproject.com/Articles/1089905/A-Custom-STL-std-allocator-Replacement-Improves-Pe
— Add custom allocators to strings and vectors
— Add custom allocators to a few test classes
— No support for aligned memory yet, so vec4<F32> and mat4<F32> vectors use the old allocation system
- Replace more std::async call with our custom task system

648 IonutCava picture IonutCava Sun 21 Feb, 2016 16:32:52 +0000

[IonutCava]
- Update copyright notice
- Move BoundingBox and BoundingSphere to a new BoundsComponent
— Add a temp hack in SceneGraphNode to update these