Facepunch / sbox-issues

176 stars 12 forks source link

Modeldoc culls bones unless an animation is present #101

Closed Jake-Rich closed 2 years ago

Jake-Rich commented 3 years ago

Describe the bug

I was having problems getting attachment points to work, and after much debugging realized modeldoc was not compiling the skeleton until I included any animation.

To Reproduce

  1. Go to modeldoc and create a new model.
  2. Add some bones.
  3. Compile and see nothing on the right side.
  4. Try to modify bone culling, still no compiled skeleton.
  5. Add a empty animation named anything.
  6. Hit compile and now your skeleton appears.

Expected behavior

Bones shouldn't be culled by default.

Additional context

https://developer.valvesoftware.com/wiki/Half-Life:_Alyx_Workshop_Tools/Modeling/Model_Troubleshooting

There is a wiki page on the valve wiki that states bones will be agressively culled without modifying bone culling settings, but modifying "BoneCullType" doesn't seem to work. Even then I think it is more intuitive to have to opt into culling but as long as we don't need to insert empty animations I'm good.

Screenshots

Bones without animation result in no skeleton image

Add in the animation and now the skeleton compiles image

garrynewman commented 3 years ago

Maybe the bone needs to be used by part of the mesh. When I added bones to the rust pistol it didn't remove the bones, but I forced the mesh to be a child of the bone (which you probably want to do to make the bone useful anyway)

garrynewman commented 3 years ago

can you explain the use case here. Should you be using attachments?

aylaylay commented 3 years ago

This is working as intended. If your model has no skinning data, you don't want it to include a skeleton. Using RenderMeshFile you can select a bone to skin to which means you'll have valid skinning data and your skeleton will be included.

You probably should just be using attachments, I can't think of any use for having a skeleton with no skinning data.

Jake-Rich commented 3 years ago

The problem afaik is you can't use attachment points without a skeleton & bones, which is how you end up with no skinning data but a skeleton.

aylaylay commented 3 years ago

I'll test it but I'm pretty sure attachments work on a non skinned model. If not then it's a seperate issue.

igniscitrinus commented 2 years ago

To expound on this, the Bone Culling Type inside the BoneMarkupList properties applies -only- when an animation is present, such as an EmptyAnim or a BindPoseAnim. This isn't necessarily an issue, but this behavior can easily lead to confusion.

aylaylay commented 2 years ago

I can have another look at this but when I first looked it didn't make sense to keep bones around with no skinning data

Fortune117 commented 2 years ago

I had a use case: for the view model of some guns, there's a 'lead gun' bone, that isn't attached to anything in the base mesh. It's designed for a gun to be parented to it. I got around this by adding an attachment to that bone.

aylaylay commented 2 years ago

From my testing, skeleton shows up if you have a mesh or an animation, I'm not sure why you'd have a model with no meshes or animations

aylaylay commented 2 years ago

I can add this but again, I'm not sure what use is a model that just has a skeleton and nothing else

DoctorGurke commented 2 years ago

I was under the impression that It'd cull bones even if there is a render mesh? So a mesh with a rig would get its Skelton culled unless there's an actual animation present

aylaylay commented 2 years ago

Seems to work fine here

aylaylay commented 2 years ago

Oh, it only doesn't work when the model has no skinning data

igniscitrinus commented 2 years ago

Oh, it only doesn't work when the model has no skinning data

It happens to meshes with skinning data that have any bones without weights assigned to them as well. It's not a common use case, but meshes that use unweighted bones as hierarchical parents for weighted bones (e.g. forearm high and low twist bones being children of one forearm bone) is a technique that some artists use in their rigs. It seems unlikely to occur in development on character models that would have some form of animation attached to them, but it's more likely to affect a model whose skeleton is being driven entirely by scripts (whatever the use case may be)

aylaylay commented 2 years ago

I've allowed it to keep bones even when there's no skinning data, let me know if that allows you to do what you need to do

igniscitrinus commented 2 years ago

No issues in my particular use case now, don't know about others.