summaryrefslogtreecommitdiff
path: root/src/KingSystem/Physics/Cloth/physClothParam.cpp
blob: 79acffb6c7df53e8fcc14b21c8de17ae7e2cc718 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "KingSystem/Physics/Cloth/physClothParam.h"
#include <filedevice/seadPath.h>

namespace ksys::phys {

ClothSetParam::ClothSetParam()
    : cloth_setup_file_path(sead::SafeString::cEmptyString, "cloth_setup_file_path",
                            "Clothセットアップファイル(.hkt)", &cloth_header_obj),
      cloth_num(0, "cloth_num", "cloth_num", &cloth_header_obj) {
    addObj(&cloth_header_obj, "ClothHeader");
    addObj(&sub_wind, "ClothSubWind");
}

ClothSetParam::~ClothSetParam() = default;

bool ClothSetParam::parse(const agl::utl::ResParameterList& res_list, sead::Heap* heap) {
    if (!res_list)
        return false;

    cloth_header_obj.applyResParameterObj(res_list.getResParameterObj(0));

    const int num_cloths = cloth_num.ref();
    if (num_cloths <= 0)
        return false;

    cloths.allocBufferAssert(num_cloths, heap);
    for (int i = 0; i < num_cloths; ++i) {
        addObj(&cloths[i], sead::FormatFixedSafeString<32>("Cloth_%d", i));
    }

    sead::Path::getFileName(&cloth_setup_file_name, cloth_setup_file_path.ref());

    return true;
}

const ClothParam* ClothSetParam::getCloth(const sead::SafeString& name) const {
    int index = -1;
    for (int i = 0, n = *cloth_num; i < n; ++i) {
        if (name == *cloths[i].name) {
            index = i;
            break;
        }
    }
    return index >= 0 && index < *cloth_num ? &cloths[index] : nullptr;
}

ClothParam::ClothParam()
    : wind_drag(5.0, "wind_drag", this), wind_frequency(5.0, "wind_frequency", this),
      wind_min_speed(-4.0, "wind_mind_speed", this), wind_max_speed(10.0, "wind_max_speed", this),
      sub_wind_factor_main(1.0, "sub_wind_factor_main", this),
      sub_wind_factor_add(0.0, "sub_wind_factor_add", this), wind_enable(true, "wind_enable", this),
      writeback_to_local(false, "writeback_to_local", this),
      name(sead::SafeString::cEmptyString, "name", this), base_bone("Root", "base_bone", this) {}

ClothSubWindParam::ClothSubWindParam()
    : sub_wind_direction(sead::Vector3f::ey, "sub_wind_direction", this),
      sub_wind_frequency(0.2, "sub_wind_frequency", this),
      sub_wind_speed(0.0, "sub_wind_speed", this) {}

}  // namespace ksys::phys