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

Box3 now supports computing minimal bounds for setFromObject #20024

Merged
merged 1 commit into from
Jan 21, 2022

Conversation

arikwex
Copy link
Contributor

@arikwex arikwex commented Aug 5, 2020

This is a draft for implementing the "minimal bounding box" idea proposed here: #17940 (comment).

I'll need to update the docs and such still, but I'd like to know if everyone's cool with the direction before going further.

@arikwex arikwex marked this pull request as draft August 5, 2020 22:47
src/math/Box3.js Outdated Show resolved Hide resolved
@arikwex arikwex marked this pull request as ready for review August 6, 2020 18:59
@arikwex
Copy link
Contributor Author

arikwex commented Aug 6, 2020

P.S. This does not support morphAttributesPosition in the same manner that BufferGeometry's bounding box computation does. It could be added if necessary.

@arikwex
Copy link
Contributor Author

arikwex commented Oct 20, 2020

@WestLangley Am I supposed to do something to nudge this PR? I'm not sure exactly what the expected PR lifecycle is for this ThreeJS.

@WestLangley WestLangley added this to the r122 milestone Oct 20, 2020
@WestLangley
Copy link
Collaborator

@arikwex I added a milestone -- that should help prevent this PR from getting lost -- but I have no control over what gets merged.

@mrdoob mrdoob modified the milestones: r122, r123 Oct 28, 2020
@mrdoob mrdoob modified the milestones: r123, r124 Nov 25, 2020
@mrdoob mrdoob modified the milestones: r124, r125 Dec 24, 2020
@mrdoob mrdoob modified the milestones: r125, r126 Jan 27, 2021
@mrdoob mrdoob modified the milestones: r126, r127 Feb 23, 2021
@mrdoob mrdoob modified the milestones: r127, r128 Mar 30, 2021
@mrdoob mrdoob modified the milestones: r128, r129 Apr 23, 2021
@mrdoob mrdoob modified the milestones: r129, r130 May 27, 2021
@mrdoob mrdoob modified the milestones: r130, r131 Jun 30, 2021
@mrdoob mrdoob modified the milestones: r131, r132 Jul 28, 2021
@mrdoob mrdoob modified the milestones: r132, r133 Aug 26, 2021
@mrdoob mrdoob modified the milestones: r133, r134 Sep 30, 2021
@mrdoob mrdoob modified the milestones: r134, r135 Oct 28, 2021
@arikwex
Copy link
Contributor Author

arikwex commented Nov 24, 2021

Dear @mrdoob, should I refer to you as

[@mrdoob]

or

[                   @mrdoob                                ]

?

With the help of this PR, I will be able to call you by EITHER name depending on your preference.

@WestLangley
Copy link
Collaborator

/ping @Mugen87 for opinion

@donmccurdy
Copy link
Collaborator

Following up on discussion in #17940, a few comments:

The behavior under minimal = false here considers morph targets; the behavior under minimal = true does not. I don't think that difference is captured in the name "minimal" ... should it consider morph targets? If so, perhaps it should consider the current state of the morph targets, rather than the maximum possible extent of the morph targets (as computeBoundingBox does)?

@mrdoob had made another suggestion in #17940 (comment), for creating a new method expandByObjectBounds. Under that naming, presumably the behavior would be:

  • expandByObjectBounds / setFromObjectBounds: Expands the Box3 conservatively and efficiently, based on a cached geometry bounding box that considers the maximum possible extent of morph targets, if present.
  • expandByObject / setFromObject: Expands the Box3 precisely and at greater expense, based on vertex data and the current state of morph targets, if present.

In terms of clarity, I might prefer that API. The downside is that it decreases performance on the existing method, with little way to communicate that to users. Brainstorming a few alternatives...

// names indicating use of `geometry.boundingBox` and maximum morph target extent...
expandByObject( object, useBounds = true )
expandByObject( object, boundingBox = true )
expandByObject( object, cached = true )
expandByObject( object, useMaximumExtent = true )

// names indicating a full scan of vertex data and current morph target state...
expandByObject( object, deep = false )
expandByObject( object, exact = false )
expandByObject( object, tight = false )

It's also possible that the geometry's bounding box was computed without considering morph targets, or at a much larger or smaller size (e.g. to account for skinning bind matrices). So I think it's probably good to be explicit about use of the bounding box rather than to use a word like "tight" or "minimal".

@mrdoob
Copy link
Owner

mrdoob commented Jan 3, 2022

expandByObject( object, exact = false )

That one sounds good to me.

As well as this one:

expandByObject( object, precise = false )

@mrdoob
Copy link
Owner

mrdoob commented Jan 3, 2022

@arikwex Sorry for the huge delay... 😬

Do you mind resolving the merge conflicts?

@arikwex
Copy link
Contributor Author

arikwex commented Jan 14, 2022

Bones rattle in a deep and dark cave. A slumbering beast awakens, hungry for a bounding box. It rebases...

Everything should be up-to-date and the signature for the expandByObject + setFromObject methods have been adjusted with the name precise instead of minimal. However, I haven't changed the morphTargets. I couldn't tell from @donmccurdy's comment if that's a requirement to merge this change.

@mrdoob mrdoob merged commit bd42765 into mrdoob:dev Jan 21, 2022
@mrdoob
Copy link
Owner

mrdoob commented Jan 21, 2022

Thanks!

@joshuaellis joshuaellis mentioned this pull request Jan 27, 2022
20 tasks
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.

4 participants