-
Notifications
You must be signed in to change notification settings - Fork 177
Model Entities: useOriginalPivot Property #951
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
Conversation
@@ -248,9 +248,9 @@ private: \ | |||
* <em>Read-only.</em> | |||
* @property {string} lodStatus - Description of the current LOD. | |||
* <em>Read-only.</em> | |||
* @property {string} numEntityUpdates - The number of entity updates that happened last frame. | |||
* @property {number} numEntityUpdates - The number of entity updates that happened last frame. |
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.
this (and some below) is unrelated cleanup to silence some warnings and fixup this JSDoc
updateRenderItems = true; | ||
model->scaleToFit(); |
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.
I don't think we need to call scaleToFit here because we call simulate below which calls scaleToFit as necessary
@@ -452,7 +465,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) { | |||
pointCollection[i][j] = scaleToFit * (pointCollection[i][j] + model->getOffset()) - registrationOffset; | |||
} | |||
} | |||
shapeInfo.setParams(type, 0.5f * extents, getCompoundShapeURL()); | |||
shapeInfo.setParams(type, 0.5f * extents, getCompoundShapeURL() + model->getSnapModelToRegistrationPoint()); |
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.
this is a hack to make sure that the same model with/without useOriginalPivot know that they have slightly different physics shapes (the difference being the offset)
@@ -723,8 +723,10 @@ ShapeType RenderablePolyVoxEntityItem::getShapeType() const { | |||
} | |||
|
|||
void RenderablePolyVoxEntityItem::setRegistrationPoint(const glm::vec3& value) { | |||
if (value != _registrationPoint) { |
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.
there's some cleanup below to make sure this stuff is all threadsafe and takes into account the pivot
@@ -302,6 +302,7 @@ class EntityItemProperties { | |||
DEFINE_PROPERTY(PROP_RELAY_PARENT_JOINTS, RelayParentJoints, relayParentJoints, bool, ENTITY_ITEM_DEFAULT_RELAY_PARENT_JOINTS); | |||
DEFINE_PROPERTY_REF(PROP_GROUP_CULLED, GroupCulled, groupCulled, bool, false); | |||
DEFINE_PROPERTY_REF(PROP_BLENDSHAPE_COEFFICIENTS, BlendshapeCoefficients, blendshapeCoefficients, QString, ""); | |||
DEFINE_PROPERTY_REF(PROP_USE_ORIGINAL_PIVOT, UseOriginalPivot, useOriginalPivot, bool, false); |
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.
DEFINE_PROPERTY_REF(PROP_USE_ORIGINAL_PIVOT, UseOriginalPivot, useOriginalPivot, bool, false); | |
DEFINE_PROPERTY_REF(PROP_USE_ORIGINAL_PIVOT, UseOriginalPivot, useOriginalPivot, bool, true); |
If using the original pivot is the standard, we should probably respect that and encourage doing the same going forward. What you export from Blender should generally show up in the same fashion in-world if at all possible.
Though, is it set to false because all existing entities without this property will get populated with false (in order to prevent breakage?)
In that case, I guess it'll have to stay false, the Create app will have to set it to "true" by default, and then we'll have to plan to set the default value to true at some point further down the line...
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.
yeah, the default needs to be false because of old content. I can change the default in the new model dialog to be true, but there’s no easy way to change the default in the future (without breaking lots of stuff).
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.
Does the domain server not have a way to parse the entity tree and upgrade them to latest? Therefore if an old entity is parsed, set it to false, and then we can set it to true by default in all places for new entities.
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.
we have a way to do this for domain content/backups, so a domain that’s upgrading to a new version could properly detect it, but there’s no way to do it for things like scripts that could be doing anything
The following links are available:
build (macOS-latest, full) build (ubuntu-18.04, android) |
The following links are available: build (ubuntu-18.04, android)
build (windows-latest, full) |
The following links are available: build (windows-latest, full) build (ubuntu-18.04, android) |
The following links are available:
build (macOS-latest, full) build (windows-latest, full) build (ubuntu-18.04, android) |
Works as intended if you use when of the generated collisions types like basic, exact, etc.. BUT if you use something like Box or Sphere collision center will be the original position. Not necessarily a bug, but this might lead to some confusion. Not sure how we should address this. Maybe if the checkbox is ticked, it does some sort of "get center" from the mesh and puts the shape collision there. EDIT: Compound shape has the same issue, even if using the same offset model. So originalpivot is not being respected on compound shapes. |
@Aitolda thanks for catching that, I think it should be fixed in the latest commit, but of course windows builds are broken here too |
The following links are available:
build (macOS-latest, full) build (ubuntu-18.04, android) |
The following links are available: build (ubuntu-18.04, full)
build (windows-latest, full) build (ubuntu-18.04, android) |
Pivot point of compound shapes still doesn't seem to be working, at least on the offset cube model I've been using.
|
@Aitolda @digisomni ok hopefully NOW it's working 😛 |
The following links are available:
build (macOS-latest, full) build (windows-latest, full) build (ubuntu-18.04, android) |
Still some major issues with using compound collisions, I see two problems potentially working together.
I've attached several models which should help demonstrate the issues. Unfortunately html doesn't like my naming scheme so I will label them here. Note, in blender Z is up, and the coordinates in my naming scheme reflects this. ArrowUp(0,0,0)Blender ArrowUp(-5,-5,0)Blender |
Thinking about it more, I'm not sure respecting the 0,0,0 (as mentioned in the post above) is even desirable. it would make sense only if you were making complex environments most of the time, and I think a json exported is a better approach for this. Just want to clarify we're talking about the distance of the pivot point from zero in blender or 3dmax, not the pivot point itself, which is the whole point of this pr. In other words, I think with the exception of the wrong rotation on fbx, the compound shape is doing what it's supposed to, and it's the mesh that's incorrectly respecting the distance from 0 |
Regarding treating 0,0,0 in blender/Maya/3dMax export as the pivot point, after doing some digging around, it unfortunately looks like even Unreal and Unity have adopted this. I assume their is some reason, but I think it's one of those things in the grand scheme are actually more difficult on artists who want to bring in elaborate scenes, but perhaps we can tackle that issue by updating the blender plugin. Either way I think once the rotation issue is solved on fbx we should move forward as is for the time being. |
after a conversation with @Aitolda, he found that other engines also have problems with non-zero pivot points (https://forum.unity.com/threads/wrong-pivot-point-from-blender-to-unity.423176/). for now, we think it's ok to move forward with this, and if we fix it in the future, we can try to do so in a backwards-compatible way. after this is merged, I'll open an issue tracking that |
Okeydokeseys! |
The following links are available: build (ubuntu-18.04, full)
build (windows-latest, full) build (ubuntu-18.04, android) |
@AleziaKurdis like I said in the description, I actually think the bounding box thing in create is somewhat helpful, as it reflects the ACTUAL position of the entity, but I agree it’s another layer of complexity. I’m open to suggestions on how to fix this...we could expose the offset to create and draw two different boxes maybe? snap to surface should still work, since it uses findRayIntersection, right? that should still work, even on pivoted models. I agree the setting should be persistent! Kalila wanted to get this in for the next release but I can sync with you to fix any bugs you find or make any improvements in a follow up in general, I think this feature request is less about eccentricity for rotations and more about making building complex scenes easier for modelers |
implements #284 resolves #793
adds a new property to Model Entities: useOriginalPivot
defaults to false (current behavior), but adds option to toggle in new model dialog
caveat: in create, the bounding box of a selected entity is centered around the actual entity position, which is now offset from the model's position when useOriginalPivot is true. I actually like this, as it reflects that offset, but maybe others have different opinions
Test plan: