fix(physics): joints were being created on load, leading to long load times
This commit is contained in:
parent
75f0892748
commit
2a60994013
2 changed files with 6 additions and 4 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Reference in a new issue