Jump to content

Drag cubes and pogo sticks.


Recommended Posts

So, here's the code:

            part.DragCubes.Procedural = true;
            part.DragCubes.ForceUpdate(true, true, true);
            part.DragCubes.SetDragWeights();

Pretty simple eh?  Well, here's the problem.  If, procedural is set to true and I try to SetDragWeights, attempting to attach a part to a mirrored part takes on all the aspects of a pogo stick ride.

I have these 3 lines running in my OnStart event.  I place any part in the hangar.  I then place a mirrored part with my partmodule on that one.  I then try to attach a part to the stack node on one of those mirrored parts (also with my partmodule).   As I move the stack nodes closer together they snap into position.  That creates a new mirrored part and executes  my OnStart. Those 3 lines then break the snap between the stack nodes and I assume the mirrored part vanishes.  Then the original part tries again to snap to the node. The mirrored part is instantly created again, running my OnStart event causing the part to vanish... ad infinitum. 

So, here's my questions

What does procedural actually do?  (ya, this is someone else's code being used with permission.)  If it set it to false, I don't get the part hopping.

Next, what does that SetDragWeights actually do?  If I leave it out, I don't get the hopping.  I spat out the array part.DragCubes.WeightedDrag after each of those lines and at no time did I see that weighted drag array change.  (and the part size, mass, etc definitely changed in the process.)

Thanks.

Link to comment
Share on other sites

Procedural rebuilds the Drag cube from the part Geometry each frame. It is slow and should only be used for stuff where the geometry has unlimited variation. And it most likely destroys any other info on the cube.

SetDragWeights set how much each of your list of cube contributes. You are supposed to lerp between 2 of the cubes with it.

And I am not sure how anything dragcube related reacts in the Editor since of lot of it is related to the FlighIntegrator and it does not run in the Editor.

 

Link to comment
Share on other sites

4 hours ago, sarbian said:

Procedural rebuilds the Drag cube from the part Geometry each frame. It is slow and should only be used for stuff where the geometry has unlimited variation. And it most likely destroys any other info on the cube.

SetDragWeights set how much each of your list of cube contributes. You are supposed to lerp between 2 of the cubes with it.

And I am not sure how anything dragcube related reacts in the Editor since of lot of it is related to the FlighIntegrator and it does not run in the Editor.

 

Thanks Sarbian.  This code is connected with @allista's AnisotripicPartResizer which allows part resizing in 2 dimensions.  For now, these parts are only resized in the editor. Once the ship is launched, their size is fixed.  Obviously, changing the drag cubes when a part gets resized will be essential.  But from what you're saying, I'm assuming 2 things.  That DragCubes.Procedural should be set to false since the drag on these parts won't change once launched and that this code could be run once in the OnStart if the scene is flight and have the same effect?  

Link to comment
Share on other sites

12 minutes ago, Fengist said:

Thanks Sarbian.  This code is connected with @allista's AnisotripicPartResizer which allows part resizing in 2 dimensions.  For now, these parts are only resized in the editor. Once the ship is launched, their size is fixed.  Obviously, changing the drag cubes when a part gets resized will be essential.  But from what you're saying, I'm assuming 2 things.  That DragCubes.Procedural should be set to false since the drag on these parts won't change once launched and that this code could be run once in the OnStart if the scene is flight and have the same effect?  

The code in AnisotropicResizable.cs#L145  does just this: recalculates drag cubes in OnStart.

Animations, however they're implemented, should use something like this: MultiGeometryAnimator.cs

Link to comment
Share on other sites

1 hour ago, Fengist said:

Right, that's where it's running now in the editor and is creating the issue with the cloned part.  I'll test it in flight and see how it goes.  Thanks guys.

Oh... It seems I wasn't paying enough attention here. Reckon I also need to fix this now :blush:

Thanks)

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...