fix(physics): joints were being created on load, leading to long load times

(cherry picked from commit 2a60994013)
This commit is contained in:
maelstrom 2025-07-18 23:57:48 +02:00
parent 99f4da8b2f
commit 259c14294c
2 changed files with 6 additions and 4 deletions

View file

@ -85,12 +85,13 @@ void Workspace::InitService() {
// Create meshes
WedgePart::createWedgeShape(physicsCommon);
}
// Sync all parts
void Workspace::OnRun() {
// Make joints
for (auto it = this->GetDescendantsStart(); it != this->GetDescendantsEnd(); it++) {
std::shared_ptr<Instance> obj = *it;
if (!obj->IsA<BasePart>()) continue;
std::shared_ptr<BasePart> part = obj->CastTo<BasePart>().expect();
if (!it->IsA<BasePart>()) continue;
std::shared_ptr<BasePart> part = it->CastTo<BasePart>().expect();
part->MakeJoints();
}

View file

@ -89,6 +89,7 @@ class DEF_INST_SERVICE_(explorer_icon="workspace") Workspace : public Service {
void updatePartPhysics(std::shared_ptr<BasePart> part);
protected:
void InitService() override;
void OnRun() override;
bool initialized = false;
public: