Skip to content

Commit

Permalink
Merge pull request #34 from miu200521358/develop
Browse files Browse the repository at this point in the history
ver5.01.08
  • Loading branch information
miu200521358 authored Nov 19, 2022
2 parents d44ae1c + 076d2f0 commit e5c3035
Show file tree
Hide file tree
Showing 9 changed files with 581 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
"name": "exec_crumb",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/../pmx_tailor/crumb/search_sode_ik.py",
"program": "${workspaceFolder}/../pmx_tailor/crumb/write_pmx_bone.py",
"console": "integratedTerminal",
"python": "${command:python.interpreterPath}",
"stopOnEntry": false,
Expand Down
8 changes: 7 additions & 1 deletion archive/Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

�@�uVMD�T�C�W���O�@���[�J���Łv

�@�@ver5.01.07
�@�@ver5.01.08

�@�@�@�@�@�@�@�@�@�@�@�@�@�@�@�@�@miu200521358

Expand Down Expand Up @@ -426,6 +426,12 @@ https://github.com/miu200521358/vmd_sizing
���@����
----------------------------------------------------------------

ver5.01.08�@�i2022/11/19�j
�@�@�E�s��C���F
�@�@�@�@�E�N�H�[�^�j�I���̃m�[�}���C�Y�����iisnan�`�F�b�N�j���ɑS�Ă�0�������ꍇ��1�����Ȃ��ƁA�s��v�Z��nan�������Ă��܂����ߏ����lj�
�@�@�@�@�E�J�����T�C�W���O�̑O�L�[�t���R�s�[���菈��������ɓ����ĂȂ������̂ŏC��


ver5.01.07�@�i2022/07/18�j
�@�@�E�s��C���F
�@�@�@�@�E�N�H�[�^�j�I���̃m�[�}���C�Y�����iisnan�`�F�b�N�j���ɁAscalar�Ƀf�t�H���g1�������Ă����ߏ���
Expand Down
8 changes: 7 additions & 1 deletion archive/β版Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@
���@rivision
----------------------------------------------------------------

VmdSizing_5.01.07_��01 (2021/04/28)
VmdSizing_5.01.08_��02 (2022/11/09)
�E�J�����T�C�W���O�̑O�L�[�t���R�s�[���菈��������ɓ����ĂȂ������̂ŏC��

VmdSizing_5.01.08_��01 (2022/11/05)
�E�N�H�[�^�j�I���̃m�[�}���C�Y�����iisnan�`�F�b�N�j���ɑS�Ă�0�������ꍇ��1�����Ȃ��ƁA�s��v�Z��nan�������Ă��܂����ߏ����lj�

VmdSizing_5.01.07_��01 (2022/04/28)
�E�N�H�[�^�j�I���̃m�[�}���C�Y�����iisnan�`�F�b�N�j���ɁAscalar�Ƀf�t�H���g1�������Ă����ߏ���
�����ꂪ��������̂́Avpd��Y=180�i0.000000,1.000000,0.000000,-0.000000;�j�������Ă�������

Expand Down
2 changes: 1 addition & 1 deletion src/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from service.SizingService import SizingService
from utils.MException import SizingException

VERSION_NAME = "ver5.01.07"
VERSION_NAME = "ver5.01.08"

# 指数表記なし、有効小数点桁数6、30を超えると省略あり、一行の文字数200
np.set_printoptions(suppress=True, precision=6, threshold=30, linewidth=200)
Expand Down
46 changes: 31 additions & 15 deletions src/mmd/VmdReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@
import hashlib
import re

from mmd.VmdData import VmdMotion, VmdBoneFrame, VmdCameraFrame, VmdInfoIk, VmdLightFrame, VmdMorphFrame, VmdShadowFrame, VmdShowIkFrame
from module.MMath import MRect, MVector3D, MVector4D, MQuaternion, MMatrix4x4 # noqa
from utils.MLogger import MLogger # noqa
from mmd.VmdData import (
VmdMotion,
VmdBoneFrame,
VmdCameraFrame,
VmdInfoIk,
VmdLightFrame,
VmdMorphFrame,
VmdShadowFrame,
VmdShowIkFrame,
)
from module.MMath import MRect, MVector3D, MVector4D, MQuaternion, MMatrix4x4 # noqa
from utils.MLogger import MLogger # noqa
from utils.MException import SizingException, MKilledException, MParseException

logger = MLogger(__name__)
Expand Down Expand Up @@ -192,8 +201,8 @@ def read_data(self):
logger.test("camera.perspective %s", camera.perspective)

# オリジナルを保持
camera.org_length = camera.org_length
camera.org_position = camera.org_position.copy()
camera.org_length = camera.length
camera.org_position = camera.position.copy()

# カメラを追加
motion.cameras[camera.fno] = camera
Expand Down Expand Up @@ -318,20 +327,23 @@ def read_data(self):
return se
except Exception as e:
import traceback
logger.critical("VMD読み込み処理が意図せぬエラーで終了しました。\n\n%s", traceback.format_exc(), decoration=MLogger.DECORATION_BOX)

logger.critical(
"VMD読み込み処理が意図せぬエラーで終了しました。\n\n%s", traceback.format_exc(), decoration=MLogger.DECORATION_BOX
)
raise e

def hexdigest(self):
sha1 = hashlib.sha1()

with open(self.file_path, 'rb') as f:
for chunk in iter(lambda: f.read(2048 * sha1.block_size), b''):
with open(self.file_path, "rb") as f:
for chunk in iter(lambda: f.read(2048 * sha1.block_size), b""):
sha1.update(chunk)

sha1.update(chunk)

# ファイルパスをハッシュに含める
sha1.update(self.file_path.encode('utf-8'))
sha1.update(self.file_path.encode("utf-8"))

return sha1.hexdigest()

Expand All @@ -350,12 +362,12 @@ def read_text(self, format_size):

# ファイルのエンコードを取得する
def get_encoding(self, fbytes, is_raise=True):
codelst = ('shift-jis', 'utf-8')
codelst = ("shift-jis", "utf-8")

for encoding in codelst:
try:
fstr = self.decode_text(fbytes, encoding, False) # bytes文字列から指定文字コードの文字列に変換
fstr = fstr.encode('utf-8') # uft-8文字列に変換
fstr = fstr.encode("utf-8") # uft-8文字列に変換
# 問題なく変換できたらエンコードを返す
logger.test("%s: encoding: %s", fstr, encoding)
return encoding
Expand All @@ -375,7 +387,7 @@ def decode_text(self, fbytes, encoding, is_raise=True):
# エンコードがない場合はNone
return None

fbytes2 = re.sub(b'\x00.*$', b'', fbytes)
fbytes2 = re.sub(b"\x00.*$", b"", fbytes)
logger.test("decode_text %s -> %s", fbytes, fbytes2)

if is_raise:
Expand All @@ -387,12 +399,16 @@ def decode_text(self, fbytes, encoding, is_raise=True):
else:
# エラーを投げない場合
try:
if encoding == 'shift-jis':
if encoding == "shift-jis":
# shift-jisは一旦cp932に変換してもう一度戻したのでテスト
return fbytes2.decode('shift_jis', errors='replace').encode('cp932', errors='replace').decode('cp932', errors='replace')
return (
fbytes2.decode("shift_jis", errors="replace")
.encode("cp932", errors="replace")
.decode("cp932", errors="replace")
)

# 変換できなかった文字は「?」に変換する
return fbytes2.decode(encoding=encoding, errors='replace')
return fbytes2.decode(encoding=encoding, errors="replace")
except Exception:
# 投げない場合はとりあえずNone
return None
Expand Down
3 changes: 3 additions & 0 deletions src/module/MMath.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,9 @@ cdef class MQuaternion:
self.data().components[np.isinf(self.data().components)] = 0
# # Scalarは1がデフォルトとなる【不要】
# self.setScalar(1 if self.scalar() == 0 else self.scalar())
if np.isclose(self.data().components, 0).all():
# すべてが0の場合、scalarだけ1に設定する
self.setScalar(1)

cpdef MMatrix4x4 toMatrix4x4(self):
cdef MMatrix4x4 mat = MMatrix4x4()
Expand Down
Loading

0 comments on commit e5c3035

Please sign in to comment.