-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Materials on Ground Primitives #6393
Changes from 28 commits
bdf302e
4fe0397
956df6c
529b5ab
7af7d47
3e5c724
0433738
2b47810
693f7e2
f9ca260
d02346b
71b6095
e7c4679
23d6dfb
62ab0ba
2cb5132
9212796
8e59e2d
5ee2f07
849c8a6
6b43300
de2268a
1d9cb79
2aba8f0
0844b9d
d9ed5c5
5e4f46c
4a00da4
d13d97f
5b0c259
e35db9d
6061880
5300fda
892b7db
ac71c04
41236c4
921a3db
75dcb60
fe8d1f7
9643b2c
2aaf979
16c7305
fbf05c8
4f580be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -509,6 +509,52 @@ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | |
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF | ||
THIS SOFTWARE. | ||
|
||
### rbush | ||
|
||
https://github.com/mourner/rbush | ||
|
||
> MIT License | ||
|
||
> Copyright (c) 2016 Vladimir Agafonkin | ||
|
||
>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. | ||
|
||
### quickselect | ||
|
||
https://github.com/mourner/quickselect | ||
|
||
> ISC License | ||
|
||
> Copyright (c) 2018, Vladimir Agafonkin | ||
|
||
>Permission to use, copy, modify, and/or distribute this software for any purpose | ||
with or without fee is hereby granted, provided that the above copyright notice | ||
and this permission notice appear in all copies. | ||
> | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | ||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF | ||
THIS SOFTWARE. | ||
|
||
### crunch | ||
|
||
https://github.com/BinomialLLC/crunch | ||
|
@@ -670,6 +716,20 @@ https://github.com/KhronosGroup/glTF-WebGL-PBR | |
>CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | ||
>OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
### ShaderFastLibs | ||
|
||
https://github.com/michaldrobot/ShaderFastLibs | ||
|
||
> The MIT License (MIT) | ||
> | ||
> Copyright (c) <2014> <Michal Drobot> | ||
> | ||
> 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. | ||
|
||
### Draco | ||
|
||
https://github.com/google/draco | ||
|
@@ -692,20 +752,20 @@ https://github.com/leizongmin/js-xss | |
|
||
> Copyright (c) 2012-2017 Zongmin Lei(雷宗民) <[email protected]> | ||
> http://ucdok.com | ||
> | ||
> | ||
> The MIT License | ||
> | ||
> | ||
> 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
define([ | ||
'../ThirdParty/mersenne-twister', | ||
'./Check', | ||
'./defaultValue', | ||
'./defined', | ||
'./DeveloperError' | ||
], function( | ||
MersenneTwister, | ||
Check, | ||
defaultValue, | ||
defined, | ||
DeveloperError) { | ||
|
@@ -857,5 +859,56 @@ define([ | |
return 1.0 - Math.exp(-(scalar * scalar)); | ||
}; | ||
|
||
/** | ||
* Computes a fast approximation of Atan for input in the range [-1, 1]. | ||
* | ||
* Based on Michal Drobot's approximation from ShaderFastLibs, | ||
* which in turn is based on "Efficient approximations for the arctangent function," | ||
* Rajan, S. Sichun Wang Inkol, R. Joyal, A., May 2006. | ||
* Adapted from ShaderFastLibs under MIT License. | ||
* | ||
* @param {Number} x An input number in the range [-1, 1] | ||
* @returns {Number} An approximation of atan(x) | ||
*/ | ||
CesiumMath.fastApproximateAtan = function(x) { | ||
//>>includeStart('debug', pragmas.debug); | ||
Check.typeOf.number('x', x); | ||
//>>includeEnd('debug'); | ||
|
||
return x * (-0.1784 * Math.abs(x) - 0.0663 * x * x + 1.0301); | ||
}; | ||
|
||
/** | ||
* Computes a fast approximation of Atan2(x, y) for arbitrary input scalars. | ||
* | ||
* Range reduction math based on nvidia's cg reference implementation: http://developer.download.nvidia.com/cg/atan2.html | ||
* | ||
* @param {Number} x An input number that isn't zero if y is zero. | ||
* @param {Number} y An input number that isn't zero if x is zero. | ||
* @returns {Number} An approximation of atan2(x, y) | ||
*/ | ||
CesiumMath.fastApproximateAtan2 = function(x, y) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and below, are |
||
//>>includeStart('debug', pragmas.debug); | ||
Check.typeOf.number('x', x); | ||
Check.typeOf.number('y', y); | ||
//>>includeEnd('debug'); | ||
|
||
// atan approximations are usually only reliable over [-1, 1] | ||
// So reduce the range by flipping whether x or y is on top. | ||
var opposite, adjacent, t; // t used as swap and atan result. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should all be declared on separate lines. |
||
t = Math.abs(x); | ||
opposite = Math.abs(y); | ||
adjacent = Math.max(t, opposite); | ||
opposite = Math.min(t, opposite); | ||
|
||
t = CesiumMath.fastApproximateAtan(opposite / adjacent); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// Undo range reduction | ||
t = Math.abs(y) > Math.abs(x) ? CesiumMath.PI_OVER_TWO - t : t; | ||
t = x < 0.0 ? CesiumMath.PI - t : t; | ||
t = y < 0.0 ? -t : t; | ||
return t; | ||
}; | ||
|
||
return CesiumMath; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
define([ | ||
'../ThirdParty/rbush', | ||
'./Check' | ||
], function( | ||
rbush, | ||
Check) { | ||
'use strict'; | ||
|
||
/** | ||
* Wrapper around rbush for use with Rectangle types. | ||
* @private | ||
*/ | ||
function RectangleCollisionChecker() { | ||
this._tree = rbush(); | ||
} | ||
|
||
function RectangleWithId() { | ||
this.minX = 0.0; | ||
this.minY = 0.0; | ||
this.maxX = 0.0; | ||
this.maxY = 0.0; | ||
this.id = ''; | ||
} | ||
|
||
RectangleWithId.fromRectangleAndId = function(id, rectangle, result) { | ||
result.minX = rectangle.west; | ||
result.minY = rectangle.south; | ||
result.maxX = rectangle.east; | ||
result.maxY = rectangle.north; | ||
result.id = id; | ||
return result; | ||
}; | ||
|
||
/** | ||
* Insert a rectangle into the collision checker. | ||
* | ||
* @param {String} id Unique string ID for the rectangle being inserted. | ||
* @param {Rectangle} rectangle A Rectangle | ||
* @private | ||
*/ | ||
RectangleCollisionChecker.prototype.insert = function(id, rectangle) { | ||
//>>includeStart('debug', pragmas.debug); | ||
Check.typeOf.string('id', id); | ||
Check.typeOf.object('rectangle', rectangle); | ||
//>>includeEnd('debug'); | ||
|
||
var withId = RectangleWithId.fromRectangleAndId(id, rectangle, new RectangleWithId()); | ||
this._tree.insert(withId); | ||
}; | ||
|
||
function idCompare(a, b) { | ||
return a.id === b.id; | ||
} | ||
|
||
var removalScratch = new RectangleWithId(); | ||
/** | ||
* Remove a rectangle from the collision checker. | ||
* | ||
* @param {String} id Unique string ID for the rectangle being removed. | ||
* @param {Rectangle} rectangle A Rectangle | ||
* @private | ||
*/ | ||
RectangleCollisionChecker.prototype.remove = function(id, rectangle) { | ||
//>>includeStart('debug', pragmas.debug); | ||
Check.typeOf.string('id', id); | ||
Check.typeOf.object('rectangle', rectangle); | ||
//>>includeEnd('debug'); | ||
|
||
var withId = RectangleWithId.fromRectangleAndId(id, rectangle, removalScratch); | ||
this._tree.remove(withId, idCompare); | ||
}; | ||
|
||
var collisionScratch = new RectangleWithId(); | ||
/** | ||
* Checks if a given rectangle collides with any of the rectangles in the collection. | ||
* | ||
* @param {Rectangle} rectangle A Rectangle that should be checked against the rectangles in the collision checker. | ||
* @returns {Boolean} Whether the rectangle collides with any of the rectangles in the collision checker. | ||
*/ | ||
RectangleCollisionChecker.prototype.collides = function(rectangle) { | ||
//>>includeStart('debug', pragmas.debug); | ||
Check.typeOf.object('rectangle', rectangle); | ||
//>>includeEnd('debug'); | ||
|
||
var withId = RectangleWithId.fromRectangleAndId('', rectangle, collisionScratch); | ||
return this._tree.collides(withId); | ||
}; | ||
|
||
return RectangleCollisionChecker; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below could be public IMO like much of the rest of this class already is.