Skip to content
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

Finish Matrix4 implementation. #129

Merged
merged 22 commits into from
Jul 25, 2012
Merged

Finish Matrix4 implementation. #129

merged 22 commits into from
Jul 25, 2012

Conversation

mramato
Copy link
Contributor

@mramato mramato commented Jul 24, 2012

  1. proper error checking.
  2. static versions of all prototype functions.
  3. Matrices are now indexed like Arrays and you can perform all matrix operations using array types.
  4. functions that provide an optional result parameter for object re-use.
  5. 100% unit test code coverage
  6. Complete documentation.
  7. Optimized the hell out of internal Matrix4 computations. Code using Matrix4 still need to be optimized to re-use objects, but Matrix4 itself is much faster now. Informal tests showed just the Skeleton going from 200fps to 215fps in Chrome and Firefox went from 17ms per frame to 16ms per frame.
  8. Updated CHANGES.

These changes are related to issues #71, #84, #86 (those issues will remain open until we address them for every Core type).

mramato and others added 16 commits July 23, 2012 09:30
There are still some regressions that need to be fixed but it now matches Matrix2 and Matrix3 API-wise.
Replace Jobs.downloadImage and getImageFromUrl with promise-based loadImage.
Change jsonp to work in a promise-based way.  Fix some other random documentation
problems I noticed along the way.
1. All toEqual calls in specs were actually doing toString result comparisons, which was cuastom some tests to pass even though they failed.  I added a toEqual override in addDefaultMatchers and fixed offending tests.
2. Fix inverseTransformation and add more tests to Matrix4.
1. Coverage up to 100%
2. Fix missing semicolons in loadImage.js
3. There's still a bug in 2D/Columbus mode that I need to track down.
Also add missing error check in Cartesian3.
1. Flesh out documentation.
2. Rename some Matrix4.fromX functions to Matrix4.computeX so they make sense.
3. Optimize internal Matrix4 computations to avoid needless array indexing and checks.
@ghost ghost assigned shunter Jul 24, 2012
});

it('createPerspectiveFieldOfView works without a result parameter', function() {
var expected = new Matrix4(1, 0, 0, 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing is a bit off here and below if you care.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jul 25, 2012

I can't figure out to expand the diff for changes to Matrix4.js, but here are a couple comments:

  • Matrix4.getTranslation needs doc, right?
  • We don't have to do it as part of this pull request, but I'd like us to soon look at Matrix4.toArray performance for setting uniforms since allocating there was a problem in the past. This can be part of the larger investigation into allocations.

@mramato
Copy link
Contributor Author

mramato commented Jul 25, 2012

Good catch on getTranslation. Looks like there are a couple other methods that can use some doc cleanup as well. I'll make those changes ASAP.

As for toArray, I definitely plan on looking into it. To ease your conscience in the mean time, I'll add that I've eliminated so many unnecessary temporary Matrix instances, that things are still faster even with the toArray call. I want to look into using cached TypeArrays in places like this as well to see how it affects performance and memory pressure. I definitely plan on doing this all in a separate effort once all of the Core cleanup I'm working on it finished. I'm optimistic that there is a ton of room for performance improvement in our code base.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jul 25, 2012

To ease your conscience in the mean time, I'll add that I've eliminated so many unnecessary temporary Matrix instances, that things are still faster even with the toArray call.

This is great and those optimizations are long overdue. However, there are several types of matrices like the projection matrix, east-north-up-to-fixed, and matrices in a transform hierarchy for a model, that will not change frame-to-frame, which we didn't help in this case. Anyway, I know you're all over it...

@mramato
Copy link
Contributor Author

mramato commented Jul 25, 2012

Okay, documentation changes are in. I found a few prototype functions that were missing doc and there were stray param tags missing in some places. Everything has correct doc now.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jul 25, 2012

@shunter review and merge this when you can, please. It's OK with me.

* All functions starting with `multiplyWith` now start with `multiplyBy` to be consistent with functions starting with `divideBy`.
* The `multiplyWithMatrix` function on each `Matrix` type was renamed to `multiply`.
* All three Matrix classes have been largely re-written for consistency and performance. The `values` property has been eliminated and Matrices are no longer immutable. Code that previously looked like `matrix = matrix.setColumn0Row0(12);` now looks like `matrix[Matrix2.COLUMN0ROW0] = 12;`. Code that previously looked like `matrix.setColumn3(cartesian3);` now looked like `matrix.setColum(3, cartesian3, matrix)`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo at the end: setColum

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed.


return a === b;
if (a !== null && b !== null && typeof a !== 'undefined' && typeof b !== 'undefined') {
return a.toString() === b.toString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a good idea? I wouldn't expect a.toEqual(b) to potentially toString them and compare. Any object without a toString override will compare equal to any other object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me and @shunter discussed the reason this code was changed and he ended up making further changes (see 41c8e7f) which improves Jasmine testing overall and ensure our equals methods are always called when available.

@mramato
Copy link
Contributor Author

mramato commented Jul 25, 2012

okay @shunter I think we're good to go.

shunter added a commit that referenced this pull request Jul 25, 2012
@shunter shunter merged commit 4c48259 into master Jul 25, 2012
pjcozzi added a commit that referenced this pull request Oct 22, 2015
updated STK Cesium examples to use fromDegrees
@anne-gropler
Copy link
Contributor

Hello,
I think the implementation of Matrix4.fromCamera is deprecated, since the camera has no .eye and no .target property, but .direction and .up and others.

@pjcozzi
Copy link
Contributor

pjcozzi commented May 18, 2016

Thanks for the report, @anne-gropler. I submitted #3927.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants