Repository navigation
fix mesh export error for unity2017.4 - #36
Conversation
jesliwang
commented
Mar 9, 2021
- Change indent_style to space。 All project files indent with space, .editorconfig's indent_style make it hard for edit
- Change 'except:' to 'except Exception as e: \n print(traceback.format_exc())'. With 'Except:', it's hard to decide the reason of failure
- Update 'AnimationClip.py' and 'Mesh.py' Refer to ’Perfare/AssetStudio‘
K0lb3
left a comment
There was a problem hiding this comment.
Thanks for the PR.
I still have some comments about some parts, but it looks good overall.
- 👍
- I've kept it without traceback because the normal user likely won't investigate it deeper and would simply open a new issue if it's important, but it's probably better with traceback so that the issue would contain the traceback as well.
- in the code comments
| bitPos %= 8 | ||
|
|
||
| scale: float = 1.0 / self.m_Range | ||
| scale: float = 1.0 / self.m_Range if self.m_Range != 0 else 0.0001 |
There was a problem hiding this comment.
C#'s division by 0 results in infinity.
This isn't correctly reflected in your version.
scale = (1.0 / self.m_Range) if self.m_Range else float("inf") would be better.
There was a problem hiding this comment.
Infinity is a better choice. I'll fix it
|
|
||
| x &= uint((1 << self.m_BitSize) - 1) # (uint)(1 << m_BitSize) - 1u | ||
| data.append(x / (scale * ((1 << self.m_BitSize) - 1)) + self.m_Start) | ||
| data.append(x / (scale * ((1 << self.m_BitSize) - 1) if self.m_BitSize != 0 else 1 ) + self.m_Start) |
There was a problem hiding this comment.
Infinity is a better choice. I'll fix it
| bits = 0 | ||
| entry = 0 | ||
| while bits << m_BitSize: | ||
| while bits < m_BitSize: |
There was a problem hiding this comment.
Have you investigated this?
AssetStudio also uses <.
AnimationClip - line 112
There was a problem hiding this comment.
Misread it ? This fix is from << to <
| if m_Channel.dimension > 0: | ||
| m_Stream = m_VertexData.m_Streams[m_Channel.stream] | ||
| channelMask = bin(m_Stream.channelMask)[::-1] | ||
| if channelMask[chn] == "1": |
There was a problem hiding this comment.
var channelMask = new BitArray(new[] { (int)m_Stream.channelMask });
byte offset = 0;
for (int i = 0; i < 6; i++)
{
if (channelMask.Get(i))The channelMask in AssetStudio "gets" a boolean value.
Since BitArray isn't natively available in python bin is used to convert the mask into bits.
The original .get(i) wouldn't fulfill the requirement if a 0 was returned,
but in your variant, a 0 would do, as "0" is True in python.
There was a problem hiding this comment.
Thank you so much for correcting the mistake!!! I I confused bin with byte
| else: | ||
| self.m_UV0 = m_CompressedMesh.m_UV.UnpackFloats( | ||
| 2, 2*4, 0, m_VertexCount) | ||
| if m_CompressedMesh.m_UV.m_NumItems >= m_VertexCount * 4: # |
There was a problem hiding this comment.
also belongs to the else previous branch,
-> indent
K0lb3
left a comment
There was a problem hiding this comment.
Looks good now.
Thanks again for the hard work.