Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Mapping vertex buffer fails after using SetMorphWeight #2495

Open
henningpohl opened this issue Sep 1, 2019 · 12 comments
Open

Mapping vertex buffer fails after using SetMorphWeight #2495

henningpohl opened this issue Sep 1, 2019 · 12 comments

Comments

@henningpohl
Copy link

I'm trying to use blend shapes, but it's not working for me. The model doesn't update.

I stepped through the code and when I change the weights with SetMorphWeight that sets morphsDirty_ and subsequently in UpdateGeometry the UpdateMorphs method is called. So far so good. When I continue through that it also seems to work. However an error then occurs inside the call to buffer->Unlock(). More specifically, that defers to SetDataRange(), where a MapBuffer() call then fails.

I'm using Direct3d11 and the corresponding implementation is:
HRESULT hr = graphics_->GetImpl()->GetDeviceContext()->Map((ID3D11Buffer*)object_.ptr_, 0, discard ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE, 0, &mappedData);
This results in an HRESULT 0x80070057 error -> E_INVALIDARG. I am not sure what is at fault here. The ID3D11Buffer pointer seems to be ok. At least it's not null.

@weitjong weitjong added the баг label Sep 2, 2019
@ghost
Copy link

ghost commented Sep 4, 2019

@henningpohl How did you create the model that contains the shape keys/morphs; did you use AssImp, the Blender exporter or maybe even something else?
...and could you try another route of you havn't already?

@henningpohl
Copy link
Author

I used the Blender exporter. The model does renders fine before I call SetMorphWeight, so at least the base mesh is not broken in any way. I also checked the mtl file (per https://urho3d.github.io/documentation/HEAD/_file_formats.html) and everything seems to be in place.

@ghost
Copy link

ghost commented Sep 4, 2019

Have you tried reproducing the issue under OpenGL?

@henningpohl
Copy link
Author

No, I have not. I first encountered this issue not with Urho3d, but with UrhoSharp and the C++ version already is an attempt to replicate this behavior. But I'll try to check tomorrow whether I can get it working with OpenGL.

@ghost
Copy link

ghost commented Sep 4, 2019

I'm assuming you are building the latest master, and not using the precompiled library.
Can you affirm this assumption?

@henningpohl
Copy link
Author

Yes, I compiled Urho3D myself (with Visual Studio 2017)

@henningpohl
Copy link
Author

Just checked and yes, when compiled for OpenGL it works.

@henningpohl
Copy link
Author

Any idea what to look for to make it work in Direct3D? For the project I'm working on OpenGL is not an option.

@henningpohl
Copy link
Author

I also just tried with Direct3D9 and there it also fails, but in a different way. After calling SetMorphWeight, the model disappears and I get continuous "Failed to create vertex declaration" (0x80004005) errors.

@ghost
Copy link

ghost commented Sep 5, 2019

Any idea what to look for to make it work in Direct3D?

I do not - for me D3D is not an option - but I'm sure the information you provided will be helpful to anyone that can help you further and may look into this.

@SuperWangKai
Copy link
Contributor

I wonder if it is because the VB is created without "dynamic"

Make sure the VB's dynamic_ is true.

/// Dynamic flag.
bool dynamic_{};

@github-actions
Copy link

Marking this stale since there has been no activity for 30 days.
It will be closed if there is no activity for another 15 days.

@github-actions github-actions bot added the stale label Mar 10, 2020
@weitjong weitjong added backlog and removed stale labels Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants