Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
SoftBodyInternal.hpp
Go to the documentation of this file.
1/**************************************************************************
2 * EngineSquared v0.1.1
3 *
4 * EngineSquared is a software package, part of the Engine² organization.
5 *
6 * This file is part of the EngineSquared project that is under MIT License.
7 * Copyright © 2025-present by @EngineSquared, All rights reserved.
8 *
9 * EngineSquared is a free software: you can redistribute it and/or modify
10 * it under the terms of the MIT License. See the project's LICENSE file for
11 * the full license text and details.
12 *
13 * @file SoftBodyInternal.hpp
14 * @brief Internal Jolt soft body reference component
15 *
16 * Stores the Jolt BodyID for soft bodies created by SoftBodySystem.
17 * This component is automatically added when a SoftBody is created.
18 *
19 * @author @EngineSquared
20 * @version 0.1.1
21 * @date 2025-12-05
22 **************************************************************************/
23
24#pragma once
25
26#include <Jolt/Jolt.h>
27#include <Jolt/Physics/Body/BodyID.h>
28#include <glm/glm.hpp>
29#include <utility>
30#include <vector>
31
32namespace Physics::Component {
33
44 JPH::BodyID bodyID;
45
48 std::vector<uint32_t> vertexMap;
49
52 glm::vec3 initialScale = glm::vec3(1.0f);
53
57 SoftBodyInternal() : bodyID(JPH::BodyID()) {}
58
63 explicit SoftBodyInternal(JPH::BodyID id) : bodyID(id) {}
64
70 SoftBodyInternal(JPH::BodyID id, std::vector<uint32_t> map) : bodyID(id), vertexMap(std::move(map)) {}
71
78 SoftBodyInternal(JPH::BodyID id, std::vector<uint32_t> map, const glm::vec3 &scale)
79 : bodyID(id), vertexMap(std::move(map)), initialScale(scale)
80 {
81 }
82
87 [[nodiscard]] bool IsValid() const { return !bodyID.IsInvalid(); }
88};
89
90} // namespace Physics::Component
Definition BoxCollider.hpp:27
SoftBodyInternal(JPH::BodyID id, std::vector< uint32_t > map)
Construct with body ID and vertex map.
Definition SoftBodyInternal.hpp:70
glm::vec3 initialScale
Definition SoftBodyInternal.hpp:52
bool IsValid() const
Check if body ID is valid.
Definition SoftBodyInternal.hpp:87
SoftBodyInternal()
Default constructor (invalid body).
Definition SoftBodyInternal.hpp:57
std::vector< uint32_t > vertexMap
Definition SoftBodyInternal.hpp:48
SoftBodyInternal(JPH::BodyID id)
Construct with body ID.
Definition SoftBodyInternal.hpp:63
SoftBodyInternal(JPH::BodyID id, std::vector< uint32_t > map, const glm::vec3 &scale)
Construct with body ID, vertex map, and initial scale.
Definition SoftBodyInternal.hpp:78
JPH::BodyID bodyID
Jolt body ID for the soft body.
Definition SoftBodyInternal.hpp:44