Skip to content

Commit 2a60994

Browse files
committed
fix(physics): joints were being created on load, leading to long load times
1 parent 75f0892 commit 2a60994

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

core/src/objects/service/workspace.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ void Workspace::InitService() {
7878
// physicsWorld->setSleepAngularVelocity(5);
7979

8080
physicsWorld->setEventListener(&physicsEventListener);
81+
}
8182

82-
// Sync all parts
83+
void Workspace::OnRun() {
84+
// Make joints
8385
for (auto it = this->GetDescendantsStart(); it != this->GetDescendantsEnd(); it++) {
84-
std::shared_ptr<Instance> obj = *it;
85-
if (!obj->IsA<Part>()) continue;
86-
std::shared_ptr<Part> part = obj->CastTo<Part>().expect();
86+
if (!it->IsA<Part>()) continue;
87+
std::shared_ptr<Part> part = it->CastTo<Part>().expect();
8788
part->MakeJoints();
8889
}
8990

core/src/objects/service/workspace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class DEF_INST_SERVICE_(explorer_icon="workspace") Workspace : public Service {
7575
void updatePartPhysics(std::shared_ptr<Part> part);
7676
protected:
7777
void InitService() override;
78+
void OnRun() override;
7879
bool initialized = false;
7980

8081
public:

0 commit comments

Comments
 (0)