summaryrefslogtreecommitdiff
path: root/src/KingSystem/Physics/RigidBody/Shape/BoxWater/physBoxWaterShape.h
blob: ec55eaedc0e0223532aed6fd0879ce8216d1e097 (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
#pragma once

#include <math/seadVector.h>
#include <prim/seadTypedBitFlag.h>
#include <thread/seadAtomic.h>
#include "KingSystem/Physics/RigidBody/Shape/physShape.h"
#include "KingSystem/Physics/physMaterialMask.h"

class hkpPlaneShape;

namespace ksys::phys {

struct BoxShapeParam;

class BoxWaterShape : public Shape {
    SEAD_RTTI_OVERRIDE(BoxWaterShape, Shape)
public:
    enum class Flag {
        IsWater = 1 << 0,
        Dirty = 1 << 1,
        /// Whether we have a transform (translation and/or rotation).
        HasTransform = 1 << 2,
    };

    static BoxWaterShape* make(const BoxShapeParam& param, sead::Heap* heap);
    BoxWaterShape* clone(sead::Heap* heap) const;

    BoxWaterShape(const BoxShapeParam& param, hkpPlaneShape* hk_shape);
    ~BoxWaterShape() override;

    void setMaterialMask(const MaterialMask& mask);
    bool setExtents(const sead::Vector3f& extents);
    bool setTranslate(const sead::Vector3f& translate);

    float getVolume() const override;
    hkpShape* getHavokShape() override;
    const hkpShape* getHavokShape() const override;
    const hkpShape* updateHavokShape() override;
    void setScale(float scale) override;
    ShapeType getType() const override { return ShapeType::BoxWater; }

    bool hasNoTransform() const {
        return mTranslate == sead::Vector3f(0, 0, 0) && mRotate == sead::Vector3f(0, 0, 0);
    }

    sead::Vector3f mExtents;
    sead::TypedBitFlag<Flag, sead::Atomic<u32>> mFlags;
    sead::Vector3f mTranslate;
    sead::Vector3f mRotate;
    hkpPlaneShape* mHavokShape{};
    MaterialMask mMaterialMask{};
};

}  // namespace ksys::phys