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
/*
   Copyright (c) 2014 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 BOUNDINGSPHERE_H_
#define BOUNDINGSPHERE_H_
#include "Core/Math/Headers/Ray.h"

namespace Divide {

class BoundingSphere {
public:
	BoundingSphere() : _computed(false),
				       _visibility(false),
				       _dirty(true),
					   _radius(0.0f)
	{
		_center.reset();
	}

	BoundingSphere(const vec3<F32>& center, F32 radius) : _computed(false),
														  _visibility(false),
														  _dirty(true),
														  _center(center),
														  _radius(radius)
	{
	}

    BoundingSphere(vectorImpl<vec3<F32> >& points) : BoundingSphere()
    {
        createFromPoints(points);
    }

	BoundingSphere(const BoundingSphere& s){
		//WriteLock w_lock(_lock);
		this->_computed = s._computed;
		this->_visibility = s._visibility;
		this->_dirty = s._dirty;
		this->_center = s._center;
		this->_radius = s._radius;
	}

	void operator=(const BoundingSphere& s){
		//WriteLock w_lock(_lock);
		this->_computed = s._computed;
		this->_visibility = s._visibility;
		this->_dirty = s._dirty;
		this->_center = s._center;
		this->_radius = s._radius;
	}

	inline void fromBoundingBox(const BoundingBox& bBox){
		_center = bBox.getCenter();
		_radius = (bBox.getMax()-_center).length();
	}

    //https://code.google.com/p/qe3e/source/browse/trunk/src/BoundingSphere.h?r=28
    void add(const BoundingSphere& bSphere){
        F32 dist = (bSphere._center - _center).length();

        if (_radius >= dist + bSphere._radius)
            return;

        if (bSphere._radius >= dist + _radius) {
            _center = bSphere._center;
            _radius = bSphere._radius;
        }

        F32 nRadius = (_radius + dist + bSphere._radius)*0.5;
        F32 ratio = (nRadius - _radius) / dist;

        _center += (bSphere._center - _center) * ratio;

        _radius = nRadius;
    }

    void addRadius(const BoundingSphere& bSphere){
        F32 dist = (bSphere._center - _center).length() + bSphere._radius;
        if (_radius < dist)
            _radius = dist;
    }

    void add(const vec3<F32>& point){
        vec3<F32> diff = point - _center;
        F32 dist = diff.length();
        if (_radius < dist) {
            F32 nRadius = (dist - _radius) * 0.5f;
            _center += diff*(nRadius / dist);
            _radius += nRadius;
       }
    }

    void addRadius(const vec3<F32>& point){
        F32 dist = (point - _center).length();
        if (_radius < dist)
            _radius = dist;
    }

    void createFromPoints(vectorImpl<vec3<F32>>& points)  {
        _radius = 0;
        I32 numPoints = (I32)points.size();

        for(vec3<F32> p : points) {
            _center += p / numPoints;
        }

        for (vec3<F32> p : points) {
            F32 distance = (p - _center).length();

            if (distance > _radius)
                _radius = distance;
        }
    }


    inline void setRadius(F32 radius) {_radius = radius;}
    inline void setCenter(const vec3<F32>& center) {_center = center;}

	inline const vec3<F32>& getCenter()   const {return _center;}
	inline F32              getRadius()   const {return _radius;}
    inline F32              getDiameter() const {return _radius * 2;}

private:
	bool _computed, _visibility,_dirty;
	vec3<F32> _center;
	F32 _radius;
	mutable SharedLock _lock;
};

}; //namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/Core/Math/BoundingVolumes/Headers/BoundingSphere.h

Diff revisions: vs.
Revision Author Commited Message
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)

260 Diff Diff k1ngp1n picture k1ngp1n Sat 03 May, 2014 19:33:41 +0000

[Ionut] [[BR]]
- More work on CSM. Reverted back to VSM to allow easier blurring and filtering [[BR]]
- Rewrote FrameBuffer classes to fix MSAA and memory leaks that occurred on resize (double creation of textures) [[BR]]
— Removed FBType. FrameBuffer types depend only on attachment types and if it’s MSAA enabled or not [[BR]]
- Rewrote RenderState classes to be API agnostic [[BR]]
- Bug fixes in math classes [[BR]]
- Changed “resolution change” logic [[BR]]
- Simplified some options in config.xml [[BR]]
- Improved per-light shadow options [[BR]]

243 Diff Diff k1ngp1n picture k1ngp1n Sun 09 Feb, 2014 20:51:49 +0000

[Ionut] [[BR]]
- performance optimizations [[BR]]

221 Diff Diff k1ngp1n picture k1ngp1n Wed 08 Jan, 2014 18:50:02 +0000

[Ionut] [[BR]]
- Merged branch “Shadows And Animations” back into trunk [[BR]]
- Added DoxygenGUI project file [[BR]]

  • Buggy *
170 Diff Diff k1ngp1n picture k1ngp1n Sun 03 Nov, 2013 17:24:57 +0000

-Moved hardware related code to a separate project [[BR]]
-More work on post-processing: [[BR]]
— HDR rendering is working, but final tonemapping needs more work [[BR]]
-Important changes in BloomPreRenderOperator.cpp, PostFX.cpp and glFrameBufferObject.cpp [[BR]]
-Trailing and leading whitespace cleanups [[BR]]

168 Diff Diff k1ngp1n picture k1ngp1n Sat 26 Oct, 2013 19:03:21 +0000

- Reworked the Camera class[[BR]]
— Now fully quaternion based [[BR]]
— Basic camera types added but not used yet (third person, first person, orbit) [[BR]]
- Cleaned up Material and Texture handling [[BR]]
- Added clipping plane support [[BR]]
— Similar to OpenGL fixed-function clip planes but fully shader driven [[BR]]
— Added a new class, “Plane”, that helps define clip planes [[BR]]
- Optimized the Singleton class to allow faster “getInstance” calls without performance penalties [[BR]]
-- “createInstance” must be called for each singleton class before usage. Or “gerOrCreateInstance” can be used, which is basically the former “getInstance” implementation [[BR]]
- Improved console logging by changing some heap allocations to stack and removing dependencies on the std::string class [[BR]]
- Added a lot of performance optimizations related to coding standards and redundant calculations [[BR]]
— e.g. Frustum AABB check didn’t need to recompute the AABB points as they were calculated already [[BR]]
— e.g. A vector did not need to be set to 0 on initialization as that is already it’s default state on creation [[BR]]
— e.g. Faster Framerate and Timing calculations by using less member variables that are not needed outsied of calling functions [[BR]]
- The SceneState now contains the SceneRenderState and is passed on to the SceneGraph’s update calls [[BR]]
- Better material export/import to/from XML format [[BR]]
- More bug fixes and cleanups [[BR]]

160 Diff Diff k1ngp1n picture k1ngp1n Wed 10 Jul, 2013 17:07:04 +0000

[Ionut] [[BR]]
- Changed licensing from LGPL to the MIT license [[BR]]
— Code can now be used in non-commercial or commercial closed or open source projects [[BR]]

148 Diff Diff k1ngp1n picture k1ngp1n Sun 14 Apr, 2013 23:07:58 +0000

[Ionut] [[BR]]
- Changed the ParamHandler from using “boost::any” to the more faster “cdiggins::any”. More info here: http://bit.ly/YVGa9X [[BR]]
- Disabled mutexes from BoundingBox. Thread safety should be applied from a higher level [[BR]]
- Fixed a bug with important light selection for scene nodes [[BR]]
- Fixed a bug with material cache involving bump maps [[BR]]
- Fixed a bug with priority vertex properties for GLSL shaders [[BR]]

146 k1ngp1n picture k1ngp1n Wed 10 Apr, 2013 13:20:15 +0000

[Ionut] [[BR]]
*Final LightBranch updates 2/3 : Main trunk merge and build test (VC90, VC100, gDebugger) [[BR]]
-Merged light branch with trunk [[BR]]
-Deleted light branch [[BR]]