Latest Threads |
Broken scripts with updat...
Forum: Obi Rope
Last Post: hariedo
23-12-2024, 05:44 PM
» Replies: 2
» Views: 152
|
Garment explodes on Andro...
Forum: Obi Cloth
Last Post: CptnFabulous
19-12-2024, 07:16 AM
» Replies: 4
» Views: 692
|
Calculating and Reproduci...
Forum: Obi Fluid
Last Post: ZacharyP
18-12-2024, 05:49 PM
» Replies: 2
» Views: 794
|
Null Reference, actor not...
Forum: Obi Rope
Last Post: josemendez
13-12-2024, 12:39 PM
» Replies: 1
» Views: 192
|
Issue with Grasping ObiRo...
Forum: Obi Rope
Last Post: josemendez
12-12-2024, 12:00 PM
» Replies: 5
» Views: 505
|
Changing extruded rendere...
Forum: Obi Rope
Last Post: aderae
10-12-2024, 07:35 PM
» Replies: 2
» Views: 265
|
Baking a rope is causing ...
Forum: Obi Rope
Last Post: josemendez
10-12-2024, 11:06 AM
» Replies: 6
» Views: 690
|
Barrier belt - changing l...
Forum: Obi Rope
Last Post: josemendez
10-12-2024, 10:42 AM
» Replies: 1
» Views: 243
|
Path editor gizmo's appea...
Forum: Obi Rope
Last Post: josemendez
10-12-2024, 09:50 AM
» Replies: 1
» Views: 235
|
Problems when using multi...
Forum: Obi Cloth
Last Post: Cat3Man
09-12-2024, 03:17 AM
» Replies: 2
» Views: 314
|
|
|
Exception Code 0xc0000409 |
Posted by: johnnychang - 02-05-2018, 08:32 AM - Forum: Obi Fluid
- Replies (3)
|
|
HI,My app has crashed.This application is a fluid, published using Unity3D.
Here is the log from Windows' Event Viewer:
Faulting application name: water.exe, version: 5.6.1.24755, time stamp: 0x5910657a
Faulting module name: libOni.dll, version: 0.0.0.0, time stamp: 0x59a32a1d
Exception code: 0xc0000409
Fault offset: 0x0006b926
Faulting process id: 0x41e8
Faulting application start time: 0x01d3e1bd5ddb1cfe
Faulting application path: C:\Users\Administrator\Desktop\water1645\water.exe
Faulting module path: C:\Users\Administrator\Desktop\water1645\water_Data\Plugins\libOni.dll
Report Id: 35857696-b35c-4a2c-b6b5-b6bfacf2aad0
Faulting package full name:
Faulting package-relative application ID:
|
|
|
WaitForAllTasks randomly uses too much CPU, and performance optimization suggestions |
Posted by: Devver - 30-04-2018, 07:54 AM - Forum: Obi Rope
- Replies (6)
|
|
Hello, I'm developing a VR project using the awesome ObiRope and would like to ask some questions and share a few optimizations suggestions that helped lowering CPU usage on my project.
The main issue: Oni.WaitForAllTasks() usually uses around 0.6ms of CPU time, but at unpredictable intervals (a few or many seconds) it takes an extra long time for a single frame: sometimes 5ms, sometimes 15ms, or even 20ms.
Here are some images from the profiler, using the bundled sample scene "FreightLift", unchanged. The higher peak is 20ms, the smaller ones are around 10ms. (This wasn't in VR)
I used the Profiler.BeginSample function around Oni.WaitForAllTasks to show it easier on the profiler, like this in the ObiArbiter's WaitForAllSolvers method, at line 41:
Code: UnityEngine.Profiling.Profiler.BeginSample("WaitForAllTasks");
Oni.WaitForAllTasks();
UnityEngine.Profiling.Profiler.EndSample();
Otherwise you can just look at the ObiSolver.FixedUpdate() times in the profiler.
This would be (maybe) acceptable for a desktop application, but in VR tracking is totally lost for some frames each time, at random intervals, making it unbearable.
Even if this couldn't be prevented somehow, it would be great if could at least be run asynchronously or split into more frames when it's taking too long. Even if it could delay rope calculations for a few frames when that happens, it would be way better than entirely freezing the game in VR.
I'm using ObiRope 3.4 with Unity 5.6.3f1 on Windows 10.
This happens using any of the 3 simulation order options on Obi Solver.
The tests above were made using a clean project with just ObiRope imported.
Also, for this project I'm currently using kinematicForParticles as true for everything, making the ropes work just as visuals and they don't physically affect anything for now (no pin constraints, just handles). I'm also using a fixed timestep value that matches the drawing update (both at 90fps), so they're synched, and like that it seems that changing the simulation order doesn't change performance. (PS: None of those changes were made to the clean project above for testing)
Do you have any suggestions to increase performance (any settings or maybe disabling anything unnecessary) for this use case?
Thank you in advance!
Performance optimization suggestions
CPU performance is very important for this VR project, so anything I could optimize helps. Here are a few changes that got me a few milliseconds back. I hope this can help someone. (The numbers below are examples taken from my machine)
1. Anisotropy doesn't seem to be needed for only ropes, but this call below still uses 0.9ms each frame, so I commented it out. This breaks the debug particle render shader, so I'll reenable this if I need to do some debugging, but not on the final build.
Location: ObiSolver.cs, line 557.
Code: // Oni.GetParticleAnisotropies(oniSolver,anisotropies,anisotropies.Length,0);
2. ObiRopeThickRenderMode's Update will keep recreating the rope's mesh every frame even if it's sleeping, not moving. That's around 1.2ms for 6 short ropes in the "RopeShowcase" scene, and will increase with length, resolution, smoothing and more ropes. I check if the rope has actually moved before allowing it to recalculate the mesh, by changing this at line 32 on the ObiRopeThickRenderMode.cs file, just above "rope.SmoothCurvesFromParticles();":
Code: private Vector3[] previousPositions = new Vector3[0];
public override void Update(Camera camera){
if (rope.section == null || rope.ropeMesh == null)
return;
// Skip mesh recalculation if rope has not changed.
bool updateMesh = false;
if(previousPositions.Length != rope.positions.Length)
{
updateMesh = true;
previousPositions = new Vector3[rope.positions.Length];
}
else
{
for(int i = 0; i < rope.positions.Length; i++)
{
Vector3 newPosition = rope.GetParticlePosition(i);
if(previousPositions[i] != newPosition)
{
previousPositions[i] = newPosition;
updateMesh = true;
}
}
}
if(!updateMesh)
return;
rope.SmoothCurvesFromParticles();
...
It would be easier to just check if the rope is sleeping, but I couldn't find any exposed method to detect this. Also, this may need some higher damping and sleep threshold values on the Obi Solver object to be effective, or the ropes may take too long to sleep.
3. When using ObiRigidbory and pin constraints, the ropes never let Unity rigidbody objects to get to sleep (they keep slightly moving the objects forever). I don't know if this is a bug, but it will force the engine to keep calculating physics for objects that aren't moving anymore, usually set to sleep until touched again, removing them from unnecessary physical calculations.
Replacing the ObiRigidbody's UpdateVelocities() method with this code can fix that. You may need to tweak those thresholds.
Code: public override void UpdateVelocities(object sender, EventArgs e){
// kinematic rigidbodies are passed to Obi with zero velocity, so we must ignore the new velocities calculated by the solver:
if (Application.isPlaying && (unityRigidbody.isKinematic || !kinematicForParticles)){
Oni.GetRigidbodyVelocity(oniRigidbody,ref oniVelocities);
Vector3 newVelocity = oniVelocities.linearVelocity - velocity;
Vector3 newAngularVelocity = oniVelocities.angularVelocity - angularVelocity;
bool updateVelocity = false;
bool updateAngularVelocity = false;
for(int i = 0; i < 3; i++){
if(Mathf.Abs(newVelocity[i]) > 0.13f)
updateVelocity = true;
if(Mathf.Abs(newAngularVelocity[i]) > 2f)
updateAngularVelocity = true;
}
if(updateVelocity)
unityRigidbody.velocity += oniVelocities.linearVelocity - velocity;
if(updateAngularVelocity)
unityRigidbody.angularVelocity += oniVelocities.angularVelocity - angularVelocity;
}
}
4. Like some people here, I needed to use ObiColliders with objects with multiple colliders, but that wouldn't work anymore. So I made this ObiCompoundCollider class. You can add it to objects in the editor as usual, or programmatically using the static AddCollider method. You don't need to add it specifically to objects with rigidbodies only; just add it to any gameobject, and it will search for children with colliders. Triggers colliders will be ignored.
Code: using UnityEngine;
using Obi;
public class ObiCompoundCollider : MonoBehaviour
{
public ObiCollisionMaterial material;
public int phase = 0;
public float thickness = 0;
public bool useDistanceFields = false;
void Awake()
{
foreach(Collider collider in GetComponentsInChildren<Collider>())
AddCollider(collider, this);
Destroy(this);
}
public static void AddCollider(Collider collider, ObiCompoundCollider obiCompoundCollider)
{
AddCollider(collider,
obiCompoundCollider.material,
obiCompoundCollider.phase,
obiCompoundCollider.thickness,
obiCompoundCollider.useDistanceFields);
}
public static void AddCollider(Collider collider, ObiCollisionMaterial material = null, int phase = 0, float thickness = 0, bool useDistanceFields = false)
{
if(collider.isTrigger)
return;
ObiCollider obiCollider = collider.GetComponent<ObiCollider>();
if(obiCollider == null || obiCollider.GetCollider() != collider)
{
collider.gameObject.SetActive(false);
obiCollider = collider.gameObject.AddComponent<ObiCollider>();
obiCollider.SetCollider(collider);
obiCollider.CollisionMaterial = material;
obiCollider.phase = phase;
obiCollider.thickness = thickness;
obiCollider.UseDistanceFields = useDistanceFields;
collider.gameObject.SetActive(true);
}
}
}
You need to also edit these files below to make it work.
In ObiCollider.cs:
Change the IsUnityColliderEnabled() method to this:
Code: protected override bool IsUnityColliderEnabled(){
Collider collider = ((Collider)unityCollider);
return collider.enabled && !collider.isTrigger;
}
Change the Awake() method to this:
Code: protected override void Awake(){
if (unityCollider == null)
unityCollider = GetComponent<Collider>();
if (unityCollider == null)
return;
base.Awake();
}
Add these new methods:
Code: public void SetCollider(Collider collider){
unityCollider = collider;
}
public Collider GetCollider(){
return (Collider)unityCollider;
}
In ObiColliderBase.cs, add these variables:
Code: protected static Transform previousTransform = null;
protected static bool previousHasChanged = false;
And change the UpdateIfNeeded() method like this:
Code: private void UpdateIfNeeded(object sender, EventArgs e){
if (unityCollider != null){
// update the collider:
bool unityColliderEnabled = IsUnityColliderEnabled();
if(previousTransform == unityCollider.transform)
unityCollider.transform.hasChanged = previousHasChanged;
previousTransform = unityCollider.transform;
previousHasChanged = unityCollider.transform.hasChanged;
if (unityCollider.transform.hasChanged ||
phase != oldPhase ||
thickness != oldThickness ||
unityColliderEnabled != wasUnityColliderEnabled){
...
With that, if you want you can also do this once at runtime to add Obi colliders to every static collider in the scene.
Code: foreach(Collider collider in FindObjectsOfType<Collider>())
{
if(collider.attachedRigidbody == null)
ObiCompoundCollider.AddCollider(collider);
}
I hope this helps, and thanks again!
|
|
|
Expected Timeline for PS4 Support |
Posted by: lemonsprinkles - 29-04-2018, 03:11 PM - Forum: Obi Rope
- Replies (5)
|
|
Hey Obi Rope team,
Thanks for making such a wonderful plug-in, it's been very helpful. I read that there are plans for supporting the PS4 platform. I was wondering if there is a timeline laid out on when to expect the plug-in to start supporting it?
Cheers,
P
|
|
|
Can Obi Cloth be paused? |
Posted by: JayDK - 28-04-2018, 11:37 PM - Forum: Obi Cloth
- Replies (2)
|
|
Hello,
I'm a prospective buyer of the Obi Cloth asset, and I'm looking for a certain functionality. I would like to know if Obi Cloth can be paused/unpaused at runtime, with the mesh holding its exact shape deformation while paused. I am designing a 2D platform game that will require the instant 180-inversion of a cloth's parent object's y-rotation on left/right user inputs (i.e. the character wearing the cloth reflects, rather than smoothly rotating towards the new bearing). I want to be able to do so mid-animation without the infinite velocity of the movement affecting the cloth. In other words, all mesh vertices should be able to remain frozen exactly in place when rotated to the opposite angle, and be able to unfreeze and resume the simulation on the next update.
The native Unity Cloth component doesn't seem able to provide such a functionality, and is generally frustrating to work with. At best, I've been able to temporarily dampen the simulation when switching directions. But even 100% dampening looks and behaves awkwardly with certain animations, as it doesn't freeze the vertices but rather is a coefficient that dampens the effect of the physics motion. Basically, it doesn't appear to be a iron-clad, all-around solution for my needs. In addition, Unity Cloth does not jibe with my game's pause function, as its simulation persists while all other graphics are paused.
If Obi can help me solve this problem, I am ready to buy today!
Thanks,
Jarod.
|
|
|
Smooth jagged edges of ObiCloth |
Posted by: PawleyBoboli - 27-04-2018, 11:13 PM - Forum: Obi Cloth
- Replies (2)
|
|
Hi Folks,
Sorry for the newbie question. I'm animating a logo in Unity with ObiCloth. It's working as I would like, but the edges of the cloth are not smooth at the end of the animation, where I am stretching it over a sphere. It has taken me a long time get the right combination of constraints and positioning, so that at the end of the animation, the "tarp" is positioned as the client wants it over the sphere.
Is there a parameter that controls how smooth the edge of the cloth will be? Or is there something in the Solver I should change? Every time I tweak something, it seems to affect a lot of other things and I have often started over. I pretty much have the elasticity and springiness I would like when the tarp is actually moving, but small parameter changes seem to affect it quite a bit. Any help is appreciated.
The attached "mars logo question.png" (with star background) shows the final step of the animation in Unity. The position and wrapping of the tarp is correct enough, it's just not smooth enough on the edges. The client's logo is attached for reference (what I'm trying to accomplish).
Thanks for any info
--Kevin
|
|
|
Obi Cloth Interactive use on VR |
Posted by: lidiamartinez - 27-04-2018, 02:36 PM - Forum: Made with Obi
- No Replies
|
|
We worked together with Virtual Voyagers to integrate Obi Cloth with their app for the fashion industry. Using VR interactively with Obi Cloth is possible and look how cool it is. Thanks!
|
|
|
'Simulate When Invisible' not respecting camera culling? |
Posted by: jabza - 26-04-2018, 10:23 PM - Forum: Obi Cloth
- Replies (1)
|
|
Hi,
In my project, I'm changing the main camera's culling mask to hide ObiCloth under certain conditions.
However, I notice ObiSolver performance still seems to take a hit depsite not being 'seen' by the camera.
Unsure if this is a bug or intended behaviour?
Also, I've noticed if an *additional* ObiSolver starts off off-screen, with 'Simulate When Invisible', this appears to cause an Editor crash.
Repro steps:
1. Create a new ObiSolver+ObiCloth GameObject, with 'Simulate When Invisible' ticked.
2. Copy and Paste the object, and move it out of camera view.
3. Hit Play.
Thanks in advance.
Much appreciated.
|
|
|
|