Skip to content

Entity update improvements 2 #830

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

Merged
merged 21 commits into from
Dec 14, 2020
Merged

Conversation

HifiExperiments
Copy link
Contributor

@HifiExperiments HifiExperiments commented Oct 21, 2020

also fixes #681

The current rendering code is a mess of locks and threads and chaos. This is an attempt to disentangle some things, hopefully resulting in some performance improvements.

The general idea is:

  • EntityItems must be threadsafe as they are accessed by multiple threads (main thread, script threads, render thread)
  • RenderableEntityItems operate on two threads, the main thread (doRenderUpdateSynchronous, needsRenderUpdate) and the render thread (doRenderUpdateAsynchronous, doRender)
  • RenderableEntityItems should do as much work as possible in doRenderUpdateAsynchronous so that we don't have to lock as much.
  • if a property is accessed on both the main thread and the render threads, it needs to be locked properly
  • needsRenderUpdate is ONLY called when an EntityItem is edited. if a Renderable needs to update constantly to check for something (like textures loading or model animation), it just needs to emit requestRenderUpdate() and needsRenderUpdate can be removed

Test plan:

@vircadia-build-notifier

@ctrlaltdavid
Copy link
Collaborator

ctrlaltdavid commented Oct 21, 2020

Initial testing ...

Clear cache (Developer > Network > Clear Disk Cache).
Restart Interface.
Enable display of Bullet collision hulls (Developer > Physics > Show Bullet Collisions).
Run script...

Two green cubes glTF model displayed initially, with expected collision hulls.
Press "o".
Model changed but collision hull not updated. (Collision hull for initial two cubes still displayed and you can walk through the single cube FBX model.)

Restart Interface, and the correct collision hull is displayed for the FBX model.
Run the script again.
This time, when the two (new) green cubes changes to the single cube FBX, the correct collision hull is displayed and you cannot walk through the model.

Delete the models and restart Interface.'
Run the script again.
Same problem occurs.

Note: Problem seems not to occur when updating the model using the Create app.

@HifiExperiments HifiExperiments linked an issue Nov 5, 2020 that may be closed by this pull request
@HifiExperiments
Copy link
Contributor Author

@SilverfishVR thanks for catching that! I think it should be fixed now

@SilverfishVR
Copy link
Contributor

PR830-705a90f:

  • missing collision hull seems fixed now 👍 However, reloading content disables it long enough for avatars to fall through, So if you stand on the default sandbox builder grid, and reload content, you fall through to land on the "Grid-Collider" box entity below, then the "builders_grid_bottom" collider (good - sub-meshes) comes back and traps you inside.
    it may not be a big issue but we would have to modify the default sandbox content to avoid this.
    In general I think we need to look at how avatar collision is handled during content load anyway.
  • Shape Entity: Broken display when alpha is set. #850 seems to work as expected 👍
  • visibility, shadows, render layer, primitive mode, renderWithZones, materialEntities, Custom Shader on entity, blendshapes and occlusion when parented to head all seems OK 👍
    tl:dr appart from less than ideal behaviour during content load all seems to work

@two-one-five two-one-five added CR Approved At least one code reviewer has approved the PR. rebuild rebuild through the GithubActions and removed needs CR (code review) labels Dec 3, 2020
@ctrlaltdavid
Copy link
Collaborator

Need to test both connecting to a domain and reloading content, in current 2020.3.2 release and this PR.

@SilverfishVR
Copy link
Contributor

did a fresh install with PR830-5e5e507 to test the collision hull loading issue:

  • I can't trigger it on domain change, only on reload.
  • It only happens if I have more than the entity I'm landing on set to "good" maybe it is still busy generating hulls for the other entities when I land, so it will sort of random if the collision is ready in time when I land 🤔
  • I don't get it on 2020.3.2, although, falling through the ground is still a thing sometimes Users sometimes stuck underground #757 so maybe time is better spend ensuring that avatar "drop" is good in all cases, that would be a seperate PR. the default sandbox can be easily fixed by moving the box collider that is already there up a bit, I think it is there because hifi knew that sometimes, just sometimes you fall 😄

@SilverfishVR
Copy link
Contributor

so, there is definitely some differences in how model scale is handled with this pr:

so, model size is correct but bounding box and collision is off. And if you rescale the rectangle in create, and switch to the sphere, it will be squished because the aspect ratio is off.

  • now in PR830-5e5e507 do the same.
    the rectangle will be squished into the 2x2x2m bounding box of the original model, if you reset dimensions, it goes back to the correct aspect but, well, going back to the sphere it will be elongated to 2x2x8m, but the bounding box and collision always match the model.

So, I think there is no "solve it all" solution to this, since only size(x,y,z) is stored, but not scale(x,y,z), wearables used to apply some form of arbitrary scale and that f'ed up all the time so I would not want to apply that kind of complex logic to models in general. The behaviour of this PR of keeping collision and bounding box in line with the displayed model is prefered, but maybe the scale should be reset when changing the model url? it will also be very annoying when iterating through models that are not to scale, having to rescale every time 🤔 pick your poison I guess 😃

@HifiExperiments
Copy link
Contributor Author

@SilverfishVR that scaling behavior is intentional, and I think it’s in line with what was originally intended by the code. the problem is that if someone manually modified the dimensions to something other than the natural dimensions, then I’d expect them to want those dimensions to carry over when the URL changes. but I agree it might not always be what they want otherwise. but I think this way is most flexible. people can always set the dimensions to the new naturalDimensions, but if we did the other behavior, there would be no way to “go back” to the OLD dimensions.

regarding reloading content, it sounds like the problem is that we need safe landing to start again, but since safe landing doesn’t work perfectly, that might not be ideal. reloading content is supposed to be more of a development tool so I think this is ok for now

@two-one-five two-one-five added rebuild rebuild through the GithubActions and removed rebuild rebuild through the GithubActions labels Dec 10, 2020
@HifiExperiments HifiExperiments added rebuild rebuild through the GithubActions and removed rebuild rebuild through the GithubActions labels Dec 11, 2020
@two-one-five two-one-five added rebuild rebuild through the GithubActions and removed rebuild rebuild through the GithubActions labels Dec 12, 2020
Copy link
Member

@digisomni digisomni left a comment

Choose a reason for hiding this comment

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

With some cursory testing over all the test cases, everything appears to be working as expected. :)

@digisomni digisomni added QA Approved The PR has been tested successfully. and removed needs testing (QA) The PR is ready for testing labels Dec 14, 2020
@digisomni digisomni merged commit 8c4ce96 into vircadia:master Dec 14, 2020
@HifiExperiments HifiExperiments deleted the update branch December 14, 2020 23:30
@digisomni digisomni removed the request for review from daleglass December 28, 2020 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix CR Approved At least one code reviewer has approved the PR. enhancement New feature or request high risk QA Approved The PR has been tested successfully. rebuild rebuild through the GithubActions renderer Touches or changes rendering threading/deadlock (beware)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shape Entity: Broken display when alpha is set. Collision hull does not update when a model is replaced.
6 participants