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
126
127
128
129
130
131
132
133
/*
   Copyright (c) 2015 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_EMITTER_H_
#define _PARTICLE_EMITTER_H_

#include "ParticleSource.h"
#include "ParticleUpdater.h"
#include "Graphs/Headers/SceneNode.h"
#include "Dynamics/Entities/Headers/Impostor.h"

/// original source code:
/// https://github.com/fenbf/particles/blob/public/particlesCode
namespace Divide {

class Texture;
class GenericVertexData;
/// A Particle emitter scene node. Nothing smarter to say, sorry :"> - Ionut
class ParticleEmitter : public SceneNode {
   public:
    ParticleEmitter();
    ~ParticleEmitter();

    /// Dummy function from SceneNode;
    bool onDraw(SceneGraphNode& sgn, RenderStage currentStage);

    /// toggle the particle emitter on or off
    inline void enableEmitter(bool state) { _enabled = state; }

    inline void setDrawImpostor(const bool state) { _drawImpostor = state; }

    bool initData(std::shared_ptr<ParticleData> particleData);
    bool updateData(std::shared_ptr<ParticleData> particleData);

    /// SceneNode concrete implementations
    bool unload();

    bool computeBoundingBox(SceneGraphNode& sgn);

    /// SceneNode test
    bool isInView(const SceneRenderState& sceneRenderState,
                  SceneGraphNode& sgn, const bool distanceCheck = false) {
        if (_enabled && _impostor) {
            return _impostor->isInView(sceneRenderState, sgn, distanceCheck);
        }

        return false;
    }

    inline void addUpdater(std::shared_ptr<ParticleUpdater> updater) {
        _updaters.push_back(updater);
    }

    inline void addSource(std::shared_ptr<ParticleSource> source) {
        _sources.push_back(source);
    }

    U32 getAliveParticleCount() const;

   protected:
    void postLoad(SceneGraphNode& sgn)  override;

    /// preprocess particles here
    void sceneUpdate(const U64 deltaTime,
                     SceneGraphNode& sgn,
                     SceneState& sceneState) override;

    bool getDrawCommands(SceneGraphNode& sgn,
                         RenderStage renderStage,
                         const SceneRenderState& sceneRenderState,
                         vectorImpl<GenericDrawCommand>& drawCommandsOut) override;

    void onCameraUpdate(SceneGraphNode& sgn, Camera& camera) override;

   private:
    void uploadToGPU();

   private:
    vec3<F32> _camUp, _camRight;
    std::shared_ptr<ParticleData> _particles;

    vectorImpl<std::shared_ptr<ParticleSource>> _sources;
    vectorImpl<std::shared_ptr<ParticleUpdater>> _updaters;

    /// create particles
    bool _enabled;
    std::atomic_bool _uploaded;
    /// draw the impostor?
    bool _drawImpostor;
    bool _updateParticleEmitterBB;
    /// used for debug rendering / editor
    ImpostorBox* _impostor;

    GenericVertexData* _particleGPUBuffer;

    U32 _particleStateBlockHash;

    ShaderProgram* _particleShader;
    ShaderProgram* _particleDepthShader;
    Texture* _particleTexture;
};

};  // namespace Divide

#endif

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

Diff revisions: vs.
Revision Author Commited Message
557 Diff Diff IonutCava picture IonutCava Tue 10 Nov, 2015 12:00:20 +0000

[IonutCava]
- Gather all rendering calls from glVertexArray and glGenericVertexData into a single function in glResources: submitRenderCommand.
— This allows both classes to interpret GenericDrawCommands in the same way
- Use unsigned ints for all hasehs instead of size_t to avoid negative number hashes (useful for debugging)

541 Diff Diff IonutCava picture IonutCava Thu 29 Oct, 2015 17:03:27 +0000

[IonutCava]
- Initial work on multi-threading the main loop (experimental. unstable):
— Multi-threaded frustum culling
— Multi-threaded particle update system

524 Diff Diff IonutCava picture IonutCava Thu 08 Oct, 2015 16:14:58 +0000

[IonutCava]
- Profiler guided optimizations:
— Replace most hashMaps with vectors where the common access pattern is linear (e.g. SceneGraphNode’s child list)
— Specify ShaderBuffer access patters at creation time to properly inform the rendering API
— Fix and optimise the LockManager & BufferLockManager classes
— Add a AtomicWrapper class that allows assignment and copy-constructions for atomic variables
-— This allows us to use vector of atomic bools for BB creation for SkinnedSubMesh objects

521 Diff Diff IonutCava picture IonutCava Tue 06 Oct, 2015 16:12:58 +0000

[IonutCava]
- Performance improvements:
— Upload an entire animation’s bone data instead of the current frame’s data and bind the appropriate frame’s transform range.
-— Sacrifices VRAM but reduces the number of RAM->VRAM uploads for animated characters
— Some refactoring in the particle code (emitter, generators, updaters, etc)
- Bugfix:
— Default texture wrap mode to REPEAT instead of CLAMP as ASSIMP seems to be failing at reading texture wrap modes and REPEAT is a safer bet.

505 Diff Diff IonutCava picture IonutCava Tue 25 Aug, 2015 22:15:49 +0000

[IonutCava]
- Finish the draw command caching System
- Cleanup AnimationComponent class

504 Diff Diff IonutCava picture IonutCava Tue 25 Aug, 2015 16:17:38 +0000

[IonutCava]
- Better caching of draw commands (W.I.P.)
- Remove unused occlusion culling code. Will be replaced with Hi-Z based culling

499 Diff Diff IonutCava picture IonutCava Thu 20 Aug, 2015 21:22:10 +0000

[IonutCava]
- UBO/SSBO proper alignment fixed (finally)
- ShaderBuffer class cleanup

494 Diff Diff IonutCava picture IonutCava Sat 15 Aug, 2015 19:09:33 +0000

[Ionut]
- Better transform tracking in PhysicsComponent
- Random code cleanups and fixes

484 Diff Diff IonutCava picture IonutCava Sun 09 Aug, 2015 13:48:51 +0000

[Ionut]
- Use explicit attribute locations with IMPrimitive objects (reducing the number of glGetAttribLocation calls to zero)
- Remove “renderCallback” system in scenes as it wasn’t used and caused unnecessary indirections
- A few cleanups and const correctness changes

471 IonutCava picture IonutCava Tue 16 Jun, 2015 15:51:32 +0000

[Ionut]
- Separated Impostor class into ImpostorSphere and ImpostorBox
— ImpostorBox is needed for the W.I.P. Occlusion queries