Violet Vreath is Shooter Game for Windows XP+(個人制作シューティングゲーム)
Revisão | 5f2d84ad7fc0dabdfc10b2337f936238b1dbf768 (tree) |
---|---|
Hora | 2019-12-17 00:51:33 |
Autor | gecchi <gecchi@XPS8...> |
Commiter | gecchi |
AniMeshちょっと最適化
@@ -59,19 +59,20 @@ public: | ||
59 | 59 | /** アニメーションコントローラ、Actor生成時にはこれが clone されてActorに保持されることになる */ |
60 | 60 | ID3DXAnimationController* _pAniControllerBase; |
61 | 61 | |
62 | - | |
62 | + /** _pFrameRoot を巡ってフレームを直列化したもの、要素番号はフレームインデックスと呼称する */ | |
63 | + std::vector<FrameWorldMatrix*> _vecAllBoneFrame; | |
63 | 64 | /** _pFrameRoot を巡ってメッシュコンテナがある描画対象フレームを直列化したもの、要素番号はただの連番 */ |
64 | 65 | std::vector<FrameWorldMatrix*> _vecDrawBoneFrame; |
65 | 66 | |
67 | + | |
66 | 68 | /** 総アニメーションセット数 */ |
67 | 69 | UINT _num_animation_set; |
68 | - /** 総アニメーションセットの配列、要素番号はアニメーションセットインデックスと呼称する */ | |
69 | - std::vector<ID3DXAnimationSet*> _vecAnimationSet; | |
70 | - /** AnimationSet から、AnimationのターゲットのBoneFrame の Nameの配列が取得できるマップ */ | |
71 | - std::map<ID3DXAnimationSet*, std::vector<LPCSTR>> _mapAnimationSet_AnimationTargetBoneFrameNames; // | |
72 | - /** フレームから、そのフレームが対象となっているアニメーションセットの配列を得る */ | |
73 | - std::map<FrameWorldMatrix*, std::vector<ID3DXAnimationSet*>> _mapBornFrame_AnimationSetList; // | |
74 | - | |
70 | + /** AnimationSet から、AnimationSetインデックスが取得できるマップ */ | |
71 | + std::map<ID3DXAnimationSet*, UINT> _mapAnimationSet_AniSetindex; | |
72 | + /** アニメーションセットインデックスから、AnimationのターゲットのBoneFrame の Nameの配列が取得できるマップ */ | |
73 | + std::map<UINT, std::vector<LPCSTR>> _mapAnimationSetIndex_AnimationTargetBoneFrameNames; | |
74 | + /** [アニメーションセットインデックス][フレームインデックス] で アニメーションセットのアニメーション対象のフレームであるかどうかが返る */ | |
75 | + bool** _papaBool_AnimationSetIndex_BoneFrameIndex_is_act; | |
75 | 76 | |
76 | 77 | int _anim_ticks_per_second; |
77 | 78 | /** 60フレーム(1秒)で1ループする場合の1フレーム辺りの時間 */ |
@@ -25,16 +25,15 @@ public: | ||
25 | 25 | |
26 | 26 | /** 前回ワールド変換の計算に使用されたフレームの変換行列の保存 */ |
27 | 27 | std::vector<D3DXMATRIX> _prevTransformationMatrixList; |
28 | - | |
29 | - std::map<FrameWorldMatrix*, std::vector<ID3DXAnimationSet*>>* _pModel_MapBornFrame_AnimationSetList; | |
30 | - ID3DXAnimationSet* _pAs0; | |
31 | - ID3DXAnimationSet* _pAs1; | |
28 | + bool** _papaBool_Model_AnimationSetIndex_BoneFrameIndex_is_act; | |
29 | + int _as0_index; | |
30 | + int _as1_index; | |
32 | 31 | public: |
33 | 32 | WorldMatStack(); |
34 | 33 | virtual ~WorldMatStack(); |
35 | 34 | virtual void registerFrameTransformationMatrix(FrameWorldMatrix* pFrame); |
36 | 35 | virtual void SetWorldMatrix( D3DXMATRIX* worldmat ); |
37 | - virtual void UpdateFrame(FrameWorldMatrix* prm_frame_world, ID3DXAnimationSet* prm_pAs1 = nullptr, ID3DXAnimationSet* prm_pAs2= nullptr); | |
36 | + virtual void UpdateFrame(FrameWorldMatrix* prm_frame_world, int prm_as0_index = -1, int prm_as1_index = -1); | |
38 | 37 | |
39 | 38 | protected: |
40 | 39 | void CalcFrameWorldMatrix(FrameWorldMatrix* frame_world); // フレームワールド行列算出再帰関数 |
@@ -35,8 +35,8 @@ _stackWorldMat() { | ||
35 | 35 | ID3DXAnimationController* pAc_cloned = _pAniMeshModel->getCloneAnimationController(); |
36 | 36 | _pPuppeteer = NEW Puppeteer(pAc_cloned); |
37 | 37 | //Frame |
38 | - _stackWorldMat._pModel_MapBornFrame_AnimationSetList = &(_pAniMeshModel->_mapBornFrame_AnimationSetList); | |
39 | - | |
38 | +// _stackWorldMat._pModel_MapBoneFrameIndex_ActAnimationSetIndexList = &(_pAniMeshModel->_mapBoneFrameIndex_ActAnimationSetIndexList); | |
39 | + _stackWorldMat._papaBool_Model_AnimationSetIndex_BoneFrameIndex_is_act = _pAniMeshModel->_papaBool_AnimationSetIndex_BoneFrameIndex_is_act; | |
40 | 40 | FrameWorldMatrix* pFrameRoot = _pAniMeshModel->_pFrameRoot; |
41 | 41 | _stackWorldMat.registerFrameTransformationMatrix(pFrameRoot); |
42 | 42 |
@@ -15,7 +15,7 @@ | ||
15 | 15 | #include "jp/ggaf/dx/texture/Texture.h" |
16 | 16 | #include "jp/ggaf/dx/util/AllocHierarchyWorldFrame.h" |
17 | 17 | |
18 | -#define MAX_FRAME_WORLD_MATRIX (8) //2以上でないとブレイクしないのでダメ | |
18 | +#define MAX_FRAME_WORLD_MATRIX (25) //2以上でないとブレイクしないのでダメ | |
19 | 19 | |
20 | 20 | using namespace GgafDx; |
21 | 21 | DWORD AniMeshModel::FVF = (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_PSIZE | D3DFVF_DIFFUSE | D3DFVF_TEX1); |
@@ -37,6 +37,8 @@ AniMeshModel::AniMeshModel(const char* prm_model_name) : Model(prm_model_name) { | ||
37 | 37 | _size_vertex_unit = sizeof(AniMeshModel::VERTEX); |
38 | 38 | _nFaces = 0; |
39 | 39 | _nVertices = 0; |
40 | + | |
41 | + _papaBool_AnimationSetIndex_BoneFrameIndex_is_act = nullptr; | |
40 | 42 | _obj_model |= Obj_GgafDx_AniMeshModel; |
41 | 43 | } |
42 | 44 |
@@ -81,7 +83,9 @@ HRESULT AniMeshModel::draw(FigureActor* prm_pActor_target, int prm_draw_set_num, | ||
81 | 83 | pTargetActor->_stackWorldMat.SetWorldMatrix(&(pTargetActor->_matWorld)); |
82 | 84 | ID3DXAnimationSet* pAs0 = pActorPuppeteer->_paAs[0]; |
83 | 85 | ID3DXAnimationSet* pAs1 = pActorPuppeteer->_paAs[1]; |
84 | - pTargetActor->_stackWorldMat.UpdateFrame(_pFrameRoot, pAs0, pAs1); | |
86 | + int as0_index = (int)_mapAnimationSet_AniSetindex[pAs0]; | |
87 | + int as1_index = pAs1 ? _mapAnimationSet_AniSetindex[pAs1] : -1; | |
88 | + pTargetActor->_stackWorldMat.UpdateFrame(_pFrameRoot, as0_index, as1_index); | |
85 | 89 | |
86 | 90 | std::vector<FrameWorldMatrix*>::iterator it_1 = _vecDrawBoneFrame.begin(); |
87 | 91 |
@@ -263,31 +267,47 @@ void AniMeshModel::restore() { | ||
263 | 267 | hr = _pAniControllerBase->AdvanceTime(0, nullptr); |
264 | 268 | checkDxException(hr, D3D_OK, "失敗しました。"); |
265 | 269 | |
266 | - | |
270 | + _vecDrawBoneFrame.clear(); | |
271 | + _vecAllBoneFrame.clear(); | |
272 | + _tmp_frame_index = 0; | |
273 | + setFrameInfo(_pFrameRoot); //フレームを廻り情報をメンバにセット | |
267 | 274 | ////// |
268 | - _vecAnimationSet.clear(); | |
269 | -// _mapAnimationSet_AniSetindex.clear(); | |
270 | - _mapAnimationSet_AnimationTargetBoneFrameNames.clear(); | |
275 | + _mapAnimationSet_AniSetindex.clear(); | |
276 | + _mapAnimationSetIndex_AnimationTargetBoneFrameNames.clear(); | |
271 | 277 | _num_animation_set = _pAniControllerBase->GetMaxNumAnimationSets(); |
272 | 278 | for (UINT ani_set_index = 0; ani_set_index < _num_animation_set; ani_set_index++) { |
273 | 279 | ID3DXAnimationSet* pAnimationSet = nullptr; |
274 | 280 | hr = _pAniControllerBase->GetAnimationSet(ani_set_index, &(pAnimationSet)); //アニメーションセット保持 |
275 | 281 | checkDxException(hr, D3D_OK, "失敗しました"); |
276 | - _vecAnimationSet.push_back(pAnimationSet); | |
277 | -// _mapAnimationSet_AniSetindex[pAnimationSet] = ani_set_index; | |
282 | + _mapAnimationSet_AniSetindex[pAnimationSet] = ani_set_index; | |
278 | 283 | int num_animation = pAnimationSet->GetNumAnimations(); |
279 | - for (int ani_index = 0; ani_index < num_animation; ++ani_index) { | |
284 | + for (UINT ani_index = 0; ani_index < num_animation; ++ani_index) { | |
280 | 285 | LPCSTR target_bone_frame_name = nullptr; |
281 | 286 | hr = pAnimationSet->GetAnimationNameByIndex(ani_index, &target_bone_frame_name); |
282 | 287 | checkDxException(hr, D3D_OK, "失敗しました"); |
283 | - _mapAnimationSet_AnimationTargetBoneFrameNames[pAnimationSet].push_back(target_bone_frame_name); | |
284 | - _TRACE_("_mapAnimationSet_AnimationTargetBoneFrameNames["<<pAnimationSet<<"] = "<<target_bone_frame_name<<""); | |
288 | + _mapAnimationSetIndex_AnimationTargetBoneFrameNames[ani_set_index].push_back(target_bone_frame_name); | |
289 | + | |
290 | + } | |
291 | + } | |
292 | + | |
293 | + _papaBool_AnimationSetIndex_BoneFrameIndex_is_act = NEW bool*[_num_animation_set]; | |
294 | + for (UINT ani_set_index = 0; ani_set_index < _num_animation_set; ani_set_index++) { | |
295 | + _papaBool_AnimationSetIndex_BoneFrameIndex_is_act[ani_set_index] = NEW bool[_tmp_frame_index+1]; | |
296 | + std::vector<LPCSTR>* pAnimationTargetBoneFrameNameList = &(_mapAnimationSetIndex_AnimationTargetBoneFrameNames[ani_set_index]); | |
297 | + for (UINT frame_index = 0; frame_index < _vecAllBoneFrame.size(); frame_index++) { | |
298 | + _papaBool_AnimationSetIndex_BoneFrameIndex_is_act[ani_set_index][frame_index] = false; | |
299 | + LPSTR frame_name = _vecAllBoneFrame[frame_index]->Name; | |
300 | + if (frame_name) { | |
301 | + for (int n = 0; n < pAnimationTargetBoneFrameNameList->size(); n++) { | |
302 | + LPCSTR animation_target_bone_frame_name = (*pAnimationTargetBoneFrameNameList)[n]; | |
303 | + if (strcmp(animation_target_bone_frame_name, frame_name) == 0) { | |
304 | + _papaBool_AnimationSetIndex_BoneFrameIndex_is_act[ani_set_index][frame_index] = true; | |
305 | + break; | |
306 | + } | |
307 | + } | |
308 | + } | |
285 | 309 | } |
286 | 310 | } |
287 | - _vecDrawBoneFrame.clear(); | |
288 | - _mapBornFrame_AnimationSetList.clear(); | |
289 | - _tmp_frame_index = 0; | |
290 | - setFrameInfo(_pFrameRoot); //フレームを廻り情報をメンバにセット | |
291 | 311 | |
292 | 312 | //境界球 |
293 | 313 | D3DXVECTOR3 vecCenter; |
@@ -478,10 +498,6 @@ void AniMeshModel::restore() { | ||
478 | 498 | pMeshContainer->MeshData.pMesh = nullptr; |
479 | 499 | } |
480 | 500 | |
481 | - | |
482 | - | |
483 | - | |
484 | - | |
485 | 501 | //////////////////////////////////////////////// |
486 | 502 | //描画時(DrawIndexedPrimitive)のパラメータリスト作成 |
487 | 503 | std::vector<AniMeshModel::INDEXPARAM> param_tmp; |
@@ -694,34 +710,10 @@ int AniMeshModel::getAnimTicksPerSecond(std::string& prm_xfile_name) { | ||
694 | 710 | } |
695 | 711 | |
696 | 712 | void AniMeshModel::setFrameInfo(FrameWorldMatrix* prm_pFrame) { |
697 | - //以下の情報を構築する | |
698 | - //・総アニメーションセットの配列、要素番号はアニメーションセットインデックスと呼称する | |
699 | - // std::vector<ID3DXAnimationSet*> _vecAnimationSet; | |
700 | - //・フレームから、そのフレームが対象となっているアニメーションセットの配列を得るMap | |
701 | - // std::map<FrameWorldMatrix*, std::vector<ID3DXAnimationSet*>> _mapBornFrame_AnimationSetList | |
702 | - //・AnimationSet から、AnimationのターゲットのBoneFrame の Nameの配列が取得できるマップ | |
703 | - // std::map<ID3DXAnimationSet*, std::vector<LPCSTR>> _mapAnimationSet_AnimationTargetBoneFrameNames | |
704 | - //・メッシュコンテナがある描画対象フレームを直列化したもの、要素番号はただの連番 | |
705 | - // std::vector<FrameWorldMatrix*> _vecDrawBoneFrame; | |
706 | - | |
707 | 713 | prm_pFrame->_frame_index = _tmp_frame_index; //フレームインデックスを保持 |
708 | 714 | _tmp_frame_index++; |
709 | - LPSTR frame_name = prm_pFrame->Name; | |
710 | - if (frame_name) { | |
711 | - //フレームから、そのフレームをアニメーションするアニメーションセットの配列を作成 | |
712 | - std::vector<ID3DXAnimationSet*>* pAnimationSetList = &(_mapBornFrame_AnimationSetList[prm_pFrame]); //構築したい配列 | |
713 | - for (UINT ani_set_index = 0; ani_set_index < _num_animation_set; ani_set_index++) { | |
714 | - ID3DXAnimationSet* pAnimationSet = _vecAnimationSet[ani_set_index]; | |
715 | - std::vector<LPCSTR>* pAnimationTargetBoneFrameNameList = &(_mapAnimationSet_AnimationTargetBoneFrameNames[pAnimationSet]); | |
716 | - for (int n = 0; n < pAnimationTargetBoneFrameNameList->size(); n++) { | |
717 | - LPCSTR animation_target_bone_frame_name = (*pAnimationTargetBoneFrameNameList)[n]; | |
718 | - if (strcmp(animation_target_bone_frame_name, frame_name) == 0) { | |
719 | - pAnimationSetList->push_back(pAnimationSet); | |
720 | - break; | |
721 | - } | |
722 | - } | |
723 | - } | |
724 | - } | |
715 | + | |
716 | + _vecAllBoneFrame.push_back(prm_pFrame); | |
725 | 717 | if (prm_pFrame->pMeshContainer) { |
726 | 718 | //メッシュコンテナ有り |
727 | 719 | _vecDrawBoneFrame.push_back(prm_pFrame); |
@@ -779,6 +771,11 @@ void AniMeshModel::release() { | ||
779 | 771 | } |
780 | 772 | |
781 | 773 | AniMeshModel::~AniMeshModel() { |
774 | + for (UINT ani_set_index = 0; ani_set_index < _num_animation_set; ani_set_index++) { | |
775 | + bool* p = _papaBool_AnimationSetIndex_BoneFrameIndex_is_act[ani_set_index]; | |
776 | + GGAF_DELETEARR(p); | |
777 | + } | |
778 | + GGAF_DELETEARR(_papaBool_AnimationSetIndex_BoneFrameIndex_is_act); | |
782 | 779 | //release(); |
783 | 780 | //はModelConnection::processReleaseResource(Model* prm_pResource) で呼び出される |
784 | 781 | } |
@@ -4,9 +4,10 @@ | ||
4 | 4 | using namespace GgafDx; |
5 | 5 | |
6 | 6 | WorldMatStack::WorldMatStack() : GgafCore::Object() { |
7 | - _pModel_MapBornFrame_AnimationSetList = nullptr; | |
8 | - _pAs0 = nullptr; | |
9 | - _pAs1 = nullptr; | |
7 | +// _pModel_MapBoneFrameIndex_ActAnimationSetIndexList = nullptr; | |
8 | + _papaBool_Model_AnimationSetIndex_BoneFrameIndex_is_act = nullptr; | |
9 | + _as0_index = -1; | |
10 | + _as1_index = -1; | |
10 | 11 | _prevTransformationMatrixList.clear(); |
11 | 12 | } |
12 | 13 |
@@ -29,7 +30,7 @@ void WorldMatStack::SetWorldMatrix(D3DXMATRIX* worldmat) { | ||
29 | 30 | _actor_world_trans_matrix = *worldmat; |
30 | 31 | } |
31 | 32 | |
32 | -void WorldMatStack::UpdateFrame(FrameWorldMatrix* prm_frame_world, ID3DXAnimationSet* prm_pAs0, ID3DXAnimationSet* prm_pAs1) { | |
33 | +void WorldMatStack::UpdateFrame(FrameWorldMatrix* prm_frame_world, int prm_as0_index, int prm_as1_index) { | |
33 | 34 | |
34 | 35 | // スタックの初期化 |
35 | 36 | while (!m_MatrixStack.empty()) |
@@ -40,8 +41,8 @@ void WorldMatStack::UpdateFrame(FrameWorldMatrix* prm_frame_world, ID3DXAnimatio | ||
40 | 41 | |
41 | 42 | // ワールド変換行列をスタックに積む |
42 | 43 | m_MatrixStack.push(&_actor_world_trans_matrix); |
43 | - _pAs0 = prm_pAs0; | |
44 | - _pAs1 = prm_pAs1; | |
44 | + _as0_index = prm_as0_index; | |
45 | + _as1_index = prm_as1_index; | |
45 | 46 | // ルートフレームからワールド変換行列を連続計算 |
46 | 47 | CalcFrameWorldMatrix(prm_frame_world); |
47 | 48 | } |
@@ -56,15 +57,11 @@ void WorldMatStack::CalcFrameWorldMatrix(FrameWorldMatrix* prm_pBoneFrame) { | ||
56 | 57 | bool is_target_frame = false; |
57 | 58 | LPSTR born_frame_name = prm_pBoneFrame->Name; |
58 | 59 | if (born_frame_name) { |
59 | - std::vector<ID3DXAnimationSet*>* pRelationAnimationSetList = &((*_pModel_MapBornFrame_AnimationSetList)[prm_pBoneFrame]); | |
60 | - int num_ani_set = pRelationAnimationSetList->size(); | |
61 | - for (int i = 0; i < num_ani_set; ++i) { | |
62 | - ID3DXAnimationSet* pRelationAnimationSet = (*pRelationAnimationSetList)[i]; | |
63 | - if (_pAs0 && _pAs0 == pRelationAnimationSet) { | |
64 | - is_target_frame = true; | |
65 | - } else if (_pAs1 && _pAs1 == pRelationAnimationSet) { | |
66 | - is_target_frame = true; | |
67 | - } | |
60 | + if (_as0_index >= 0 && _papaBool_Model_AnimationSetIndex_BoneFrameIndex_is_act[_as0_index][prm_pBoneFrame->_frame_index]) { | |
61 | + is_target_frame = true; | |
62 | + | |
63 | + } else if (_as1_index >= 0 && _papaBool_Model_AnimationSetIndex_BoneFrameIndex_is_act[_as1_index][prm_pBoneFrame->_frame_index]) { | |
64 | + is_target_frame = true; | |
68 | 65 | } |
69 | 66 | } |
70 | 67 |
@@ -77,11 +74,6 @@ void WorldMatStack::CalcFrameWorldMatrix(FrameWorldMatrix* prm_pBoneFrame) { | ||
77 | 74 | D3DXMatrixMultiply(&(prm_pBoneFrame->_world_trans_matrix), pMatrix, pStackMat); |
78 | 75 | } |
79 | 76 | |
80 | -// if (prm_pBoneFrame->pMeshContainer) { | |
81 | -// // 引数のフレームに対応するワールド変換行列を計算 | |
82 | -// _vecDrawBoneFrame.push_back(prm_pBoneFrame); | |
83 | -// } | |
84 | - | |
85 | 77 | // 子フレームがあればスタックを積んで、子フレームのワールド変換座標の計算へ |
86 | 78 | if (prm_pBoneFrame->pFrameFirstChild) { |
87 | 79 | m_MatrixStack.push(&(prm_pBoneFrame->_world_trans_matrix)); |
@@ -1 +1 @@ | ||
1 | -#define VERSION "VER 0.30.6715" | |
1 | +#define VERSION "VER 0.30.6717" |