![]() |
Running Obi Cloth In Edit Mode - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html) +--- Thread: Running Obi Cloth In Edit Mode (/thread-2657.html) |
Running Obi Cloth In Edit Mode - berko - 22-12-2020 Hi, I want to run obi cloth in edit mode during level design process. I could not see any info about this. Pls help. Thanks RE: Running Obi Cloth In Edit Mode - josemendez - 22-12-2020 (22-12-2020, 10:07 AM)berko Wrote: Hi, Hi there, You can derive from the ObiUpdater class to update Obi whenever you want, including at edit time. See: http://obi.virtualmethodstudio.com/tutorials/updaters.html Also look up ObiUpdater in the API docs: http://obi.virtualmethodstudio.com/api.html You'll see it has several methods to advance the simulation: BeginStep, Substep, EndStep, and Interpolate. You can also check the different existing subclasses of ObiUpdater (ObiFixedUpdater, ObiLateUpdater, etc) for examples on how/when to call these methods. The typical pattern would be: Code: BeginStep(); So: one call to BeginStep() (performs collision detection and clears up cached data), one or more calls to Substep() (advances simulation), one call to EndStep(); (calls collision callbacks) and one call to Interpolate(); (interpolates physics state and triggers rendering). cheers! RE: Running Obi Cloth In Edit Mode - berko - 22-12-2020 (22-12-2020, 10:16 AM)josemendez Wrote: Hi there,Hi, I tried bu unity crashes at m_SolverImpl.CollisionDetection(stepTime) at line 1396 in obiolver. I could not figure out. I have modified FixedUpdater to run in EditMode. RE: Running Obi Cloth In Edit Mode - josemendez - 23-12-2020 (22-12-2020, 09:49 PM)berko Wrote: Hi, I tried bu unity crashes at m_SolverImpl.CollisionDetection(stepTime) at line 1396 in obiolver. I could not figure out. I have modified FixedUpdater to run in EditMode.FixedUpdate is not called in editor. Simply adding [ExecuteInEditMode] to an existing updater won’t do, you need to write your own and call its methods when necessary. Also note that actors will need to have their Awake() method called. Will write an example for you. RE: Running Obi Cloth In Edit Mode - berko - 23-12-2020 (23-12-2020, 08:29 AM)josemendez Wrote: FixedUpdate is not called in editor. Simply adding [ExecuteInEditMode] to an existing updater won’t do, you need to write your own and call its methods when necessary.An example would be be great Jose. Thanks RE: Running Obi Cloth In Edit Mode - josemendez - 23-12-2020 Turns out collisions and a few other bits weren't really ready for in-editor simulation. In addition to extending ObiUpdater, you will need to make a few changes: - Add [ExecuteInEditMode] to BurstColliderWorld.cs/OniColliderWorld.cs. This will allow collision data structures to be initialized in-editor. - Add [ExecuteInEditMode] to ObiParticleAttachment.cs. This will allow attachments to run in edit mode. - Comment out lines 1106-1126 of ObiActor.cs. These are intended to override renderable particle positions at edit time, to allow particle positions to reflect changes to the actor's transform in absence of simulation. - Line 146 of ObiClothRendererBase.cs, remove "Application.isPlaying" from the if() statement. This was intended to reduce work done in-editor. With these changes, you can then use this ObiUpdater subclass to step the simulation forward in editor by clicking the inspector's "update" button. Code: using UnityEngine; If you describe your use case more accurately, I can come up with better solutions for it after Christmas. Potential improvements include writing an in-editor fixed timestep loop to circumvent the absence of FixedUpdate() calls, supporting simulation reset, updating Unity's rigidbody physics in sync, and some others. cheers! |