summaryrefslogtreecommitdiff
path: root/src/KingSystem/Physics/RigidBody/Shape/CharacterPrism/physCharacterPrismShape.h
blob: 1724835bbb00e96f9fa8732ffac42430b19cc1bc (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
#pragma once

#include <math/seadVector.h>
#include "KingSystem/Physics/RigidBody/Shape/physShape.h"

namespace ksys::phys {

class PolytopeShape;

struct CharacterPrismShapeParam {
    float radius = 0.35;
    float ring0_distance = 0.5;
    float ring1_distance = 1.5;
    float end_vertex_distance = 1.8;
    sead::Vector3f offset = sead::Vector3f::zero;
    CommonShapeParam common;
};

/// A "stretched bipyramid" shape with a top and bottom vertex and two rings of eight vertices
/// between them.
class CharacterPrismShape : public Shape {
    SEAD_RTTI_OVERRIDE(CharacterPrismShape, Shape)

public:
    ~CharacterPrismShape() override;

    static CharacterPrismShape* make(const CharacterPrismShapeParam& param, sead::Heap* heap);
    CharacterPrismShape* clone(sead::Heap* heap) const;

    void setMaterialMask(const MaterialMask& mask);
    const MaterialMask& getMaterialMask() const;

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

    PolytopeShape* getUnderlyingShape() const { return mShape; }

private:
    static constexpr int RING_VERTEX_NUM = 8;
    static constexpr int SHAPE_VERTEX_NUM = RING_VERTEX_NUM * 2 + 2;

    /// The underlying shape for this character prism shape.
    PolytopeShape* mShape{};

    float mRadius;
    float mRing0Distance;
    float mRing1Distance;
    float mEndVertexDistance;
    sead::Vector3f mOffset;
    float mScale;
};

}  // namespace ksys::phys