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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include "Headers/PhysXScene.h"

#include "Managers/Headers/SceneManager.h"
#include "Rendering/RenderPass/Headers/RenderQueue.h"
#include "Core/Headers/ParamHandler.h"

namespace Divide {

REGISTER_SCENE(PhysXScene);

enum PhysXStateEnum{
    STATE_ADDING_ACTORS = 0,
    STATE_IDLE = 2,
    STATE_LOADING = 3
};

static std::atomic<PhysXStateEnum > s_sceneState;

//begin copy-paste
void PhysXScene::preRender(){
	_currentSky->getNode<Sky>()->setSunProperties(_sunvector, _sun->getDiffuseColor());
}
//<<end copy-paste

void PhysXScene::processGUI(const U64 deltaTime){
    D32 FpsDisplay = getSecToMs(0.3);
    if (_guiTimers[0] >= FpsDisplay){
        _GUI->modifyText("fpsDisplay", "FPS: %3.0f. FrameTime: %3.1f", 
                         ApplicationTimer::getInstance().getFps(), ApplicationTimer::getInstance().getFrameTime());
        _GUI->modifyText("RenderBinCount", "Number of items in Render Bin: %d", GFX_RENDER_BIN_SIZE);
        _guiTimers[0] = 0.0;
    }
    Scene::processGUI(deltaTime);
}

void PhysXScene::processInput(const U64 deltaTime){

}

bool PhysXScene::load(const stringImpl& name, CameraManager* const cameraMgr, GUI* const gui){
    s_sceneState = STATE_LOADING;
    //Load scene resources
    bool loadState = SCENE_LOAD(name,cameraMgr,gui,true,true);
    //Add a light
    vec2<F32> sunAngle(0.0f, RADIANS(45.0f));
    _sunvector = vec3<F32>(-cosf(sunAngle.x) * sinf(sunAngle.y),-cosf(sunAngle.y),-sinf(sunAngle.x) * sinf(sunAngle.y));
	_sun = addLight(LIGHT_TYPE_DIRECTIONAL)->getNode<DirectionalLight>();
    _sun->setDirection(_sunvector);
	_currentSky = addSky(CreateResource<Sky>(ResourceDescriptor("Default Sky")));
    s_sceneState = STATE_IDLE;
    return loadState;
}

bool PhysXScene::loadResources(bool continueOnErrors){
    _GUI->addText("fpsDisplay",               //Unique ID
                  vec2<I32>(60,20),           //Position
                  Font::DIVIDE_DEFAULT,       //Font
                  vec3<F32>(0.0f,0.2f, 1.0f), //Color
                  "FPS: %s",0);               //Text and arguments
    _GUI->addText("RenderBinCount",
                  vec2<I32>(60,30),
                  Font::DIVIDE_DEFAULT,
                  vec3<F32>(0.6f,0.2f,0.2f),
                  "Number of items in Render Bin: %d",0);

    _guiTimers.push_back(0.0); //Fps
    renderState().getCamera().setFixedYawAxis(false);
    renderState().getCamera().setRotation(-45/*yaw*/,10/*pitch*/);
    renderState().getCamera().setEye(vec3<F32>(0,30,-40));
    renderState().getCamera().setFixedYawAxis(true);
    ParamHandler::getInstance().setParam("rendering.enableFog",false);
    ParamHandler::getInstance().setParam("postProcessing.bloomFactor",0.1f);
    return true;
}

bool PhysXScene::unload(){
    return Scene::unload();
}

void PhysXScene::createStack(U32 size){
    F32 stackSize = size;
    F32 CubeSize = 1.0f;
    F32 Spacing = 0.0001f;
    vec3<F32> Pos(0, 10 + CubeSize,0);
    F32 Offset = -stackSize * (CubeSize * 2.0f + Spacing) * 0.5f + 0;

    while(s_sceneState == STATE_ADDING_ACTORS);

    s_sceneState = STATE_ADDING_ACTORS;

    while(stackSize){
        for(U16 i=0;i<stackSize;i++){
            Pos.x = Offset + i * (CubeSize * 2.0f + Spacing);
            PHYSICS_DEVICE.createBox(Pos,CubeSize);
        }
        Offset += CubeSize;
        Pos.y += (CubeSize * 2.0f + Spacing);
        stackSize--;
    }

    s_sceneState = STATE_IDLE;
}

void PhysXScene::createTower(U32 size){
    while(s_sceneState == STATE_ADDING_ACTORS);
    s_sceneState = STATE_ADDING_ACTORS;

    for(U8 i = 0 ; i < size; i++)
        PHYSICS_DEVICE.createBox(vec3<F32>(0,5.0f+5*i,0),0.5f);
    
    s_sceneState = STATE_IDLE;
}


bool PhysXScene::onKeyUp(const Input::KeyEvent& key){
    switch(key._key)	{
        default: break;
        case Input::KeyCode::KC_5:{
            _paramHandler.setParam("simSpeed", IS_ZERO(_paramHandler.getParam<F32>("simSpeed")) ? 1.0f : 0.0f);
            PHYSICS_DEVICE.updateTimeStep();
            }break;
        case Input::KeyCode::KC_1:{
            static bool hasGroundPlane = false;
            if(!hasGroundPlane){
                PHYSICS_DEVICE.createPlane(vec3<F32>(0,0,0),random(100.0f, 200.0f));
                hasGroundPlane = true;
            }
            }break;
        case Input::KeyCode::KC_2:
            PHYSICS_DEVICE.createBox(vec3<F32>(0,random(10,30),0),random(0.5f,2.0f));
            break;
        case Input::KeyCode::KC_3:{
            Kernel* kernel = Application::getInstance().getKernel();
            Task_ptr e(kernel->AddTask(0, 1, DELEGATE_BIND(&PhysXScene::createTower, this, (U32)random(5, 20))));
			registerTask(e);
			e->startTask();
            }break;
        case Input::KeyCode::KC_4:{
            Kernel* kernel = Application::getInstance().getKernel();
            Task_ptr e(kernel->AddTask(0, 1, DELEGATE_BIND(&PhysXScene::createStack, this, (U32)random(5, 10))));
			registerTask(e);
			e->startTask();
        } break;
    }
    return Scene::onKeyUp(key);
}

bool PhysXScene::mouseMoved(const Input::MouseEvent& key){
    return Scene::mouseMoved(key);
}

bool PhysXScene::mouseButtonReleased(const Input::MouseEvent& key, Input::MouseButton button){
    return Scene::mouseButtonReleased(key,button);;
}

};

Commits for Divide-Framework/trunk/Source Code/Scenes/PhysXScene/PhysXScene.cpp

Diff revisions: vs.
Revision Author Commited Message
331 Diff Diff IonutCava picture IonutCava Sat 06 Dec, 2014 20:53:45 +0000

[Ionut]
- Limited line length to 132 characters to improve readability and diff-comparisons
- Refactored memory allocation/deallocation functions
- Fixed a few compatibility issues with HashMap.h
- Fixed a bug in GPU Skinning shaders (cast a float to int)

326 Diff Diff IonutCava picture IonutCava Tue 30 Sep, 2014 21:11:32 +0000

[Ionut]
- Fixed more memory leaks
- Simplified Task interface and timing System
- Improved compatibility between Boost, STL and EASTL with random combinations of vectors, strings and maps
- Simplified Light class by removing the “slot” member
- Random optimizations

322 Diff Diff IonutCava picture IonutCava Sat 06 Sep, 2014 20:33:47 +0000

[Ionut]
- Refactored most of Boost related code to be C++11 based
— Boost is only used for ThreadPool, Mutex handling, XML parsing and networking (ASIO)
— Function binds, threads, regex, NonCopyable base, Hashing algorithms and more are now using C++11 libraries
- Replaced all FOR_EACH calls with standard, range, “for” calls

321 Diff Diff IonutCava picture IonutCava Wed 03 Sep, 2014 22:05:15 +0000

[Ionut]
- Added support (and enabled by default) for the EASTL library (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html / https://github.com/paulhodge/EASTL)
— Strings, vectors and hash_maps can be combined from EASTL, STL and Boost (not all combinations work. e.g. EASTL strings with STL/Boost containers due to the lack of a proper hash function)

320 Diff Diff IonutCava picture IonutCava Sun 31 Aug, 2014 21:45:33 +0000

[Ionut]
- More AI work (entity captures flag and returns it to base)

318 Diff Diff IonutCava picture IonutCava Sat 30 Aug, 2014 17:35:53 +0000

[Ionut]
- Wrapped the entire code in a “Divide” namespace
- VertexBuffers now call “shrink_to_fit” on all internal data storage
- Improved some vector performance by preferring “emplace_back” instead of “push_back” + proepr usage of reserve / resize
- Wrapped OIS specific types and classes in Divide::Input namespace
- Added the messageBox.layout file (forgot it in the previous few commits)

309 Diff Diff IonutCava picture IonutCava Sat 16 Aug, 2014 22:57:33 +0000

[Ionut]
- Added an InputAggregator interface to standardize input event handling

307 Diff Diff IonutCava picture IonutCava Tue 12 Aug, 2014 19:45:12 +0000

[Ionut]
- More editor work:
— Per object skeleton rendering, bounding box rendering and shadow map toggling
— Full screen depth preview toggle
— Text entry based transforms

264 Diff Diff k1ngp1n picture k1ngp1n Tue 27 May, 2014 13:04:38 +0000

[Ionut] [[BR]]
- New camera system: [[BR]]
— Stack based (push/pop active camera) [[BR]]
— Per camera frustum [[BR]]
— Per camera projection [[BR]]
— Shadow mapping now uses the new camera system (each light has a shadow camera) [[BR]]
[[BR]]
- New terrain, water and vegetation system: [[BR]]
— Direct import of terrain from L3DT both as 8-bit grayscale and 16-bit raw formats [[BR]]
— Multiple alpha maps for texture splatting support [[BR]]
— Per texture detail map support [[BR]]
— Transform feedback based visibility culling for vegetation [[BR]]
— Alpha-map based vegetation placing on terrain [[BR]]
— Water now uses a refraction map instead of alpha blending for better refraction effects [[BR]]
[[BR]]
- SceneGraph improvements: [[BR]]
— Better bounding box updates from child to parent [[BR]]
— Better onDraw / postDraw implementation [[BR]]
[[BR]]
- Performance improvements: [[BR]]
— Batch 2D rendering tasks together as much as possible[[BR]]
— Improve renderStateBlock hash generation for better sorting [[BR]]
— Move most state related gfx changes from API implementation to the GFXDevice class [[BR]]
— Move viewport stack to the GFXDevice class [[BR]]
— Added various performance counters (frame duration with round-robin query system, draw call count, etc) [[BR]]
— Fixed and improved clip plane management [[BR]]
— Delete client-side texture data after GPU upload [[BR]]
[[BR]]
- New features: [[BR]]
— Added callback support to the Task class so that a specific task may call a function in the main thread upon completion [[BR]]
— Added mouse-wheel zoom support to Orbit/ThirdPerson cameras [[BR]]
— Added 2D Texture Array support (e.g. used for terrain textures) [[BR]]

259 k1ngp1n picture k1ngp1n Sun 27 Apr, 2014 18:24:52 +0000

[Ionut][[BR]]
- Implemented Exponential Stable Cascaded Shadow Maps for directional lights (still buggy, but basically working) [[BR]]
— CSM settings (resolution, number of splits, etc) are part of the scene render state [[BR]]
- SGN can skip rendering for the current frame if they are not ready (e.g. OnDraw can now return false or materials can fail to bind) [[BR]]
- Frustum class is now using the Plane class [[BR]]
- Removed Math SIMD implementation as the compiler generated code will always be faster and safer [[BR]]
- Added a “STUBBED” macro for outputing to the error stream of important messages (instead of using #pragma message) [[BR]]
- Added “freeze time” logic to pause/resume updates with or without freezing the GUI too [[BR]]
- Added “processGUI” method the every Scene class to separate time-sensitive GUI updates from game logic loop [[BR]]
- GLSL <-> Vertex Buffer bind locations are automatically set for every vertex shader [[BR]]
- Added basic support for compute shaders [[BR]]
- Removed most OS define checks to make porting to a new platform easier [[BR]]
- Texture transparency check per-pixel is now using OpenMP [[BR]]
- Texture samplers can now set a border color for CLAMP_TO_BORDER wrap mode [[BR]]
- Removed “Object” suffix from GFX Classes (pixel buffer, vertex buffer, frame buffer, etc) [[BR]]
- Stop processing scene input when application looses focus [[BR]]
- SceneGraphNode class is now responsible for updating SGNComponents on draw and calling its _node’s OnDraw method [[BR]]
- UBOs can now list all of the active uniforms inside a block with info such as type and offset [[BR]]
- Removed deprecated ‘GLCheck’ macro [[BR]]
- A lot of bug fixes and performance improvements in various places [[BR]]