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

This commit is contained in:
maelstrom 2025-07-18 23:44:13 +02:00
parent 75f0892748
commit 2a60994013
2 changed files with 6 additions and 4 deletions

View file

@ -78,12 +78,13 @@ void Workspace::InitService() {
// physicsWorld->setSleepAngularVelocity(5);
physicsWorld->setEventListener(&physicsEventListener);
}
// 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<Part>()) continue;
std::shared_ptr<Part> part = obj->CastTo<Part>().expect();
if (!it->IsA<Part>()) continue;
std::shared_ptr<Part> part = it->CastTo<Part>().expect();
part->MakeJoints();
}

View file

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