shadowmage45 / TexturesUnlimited

KSP Shader, Texture, and Modeling Utilities
GNU General Public License v3.0
29 stars 17 forks source link

Possible incompatibility with Procedural Fairings #10

Closed Drakenexh closed 7 years ago

Drakenexh commented 7 years ago

Experiencing violent explosions/disassembles when staging PF fairing. Works fine with stock fairings. Attached, craft file to reproduce issue.

PF Test.zip

Console/log output:

[LOG 23:06:20.928] DragCubeSystem: Rendering procedural drag for KW2mFairingPFE
[LOG 23:06:20.970] DragCubeSystem: Rendering procedural drag for KzProcFairingSide4
[LOG 23:06:20.999] DragCubeSystem: Rendering procedural drag for KzProcFairingSide4
[LOG 23:06:22.631] 11/14/2017 11:06:22 PM,ShipManifest-DfWrapper,Attempting to Grab DeepFreeze Types...
[LOG 23:06:27.175] SSTUReflectionManager vesselCreated() : KzProcFairingSide4 (Vessel) :: KSPShaderTools.ReflectionManager+VesselReflectionData
[LOG 23:06:27.177] SSTUReflectionManager vesselCreated() : KzProcFairingSide4 (Vessel) :: KSPShaderTools.ReflectionManager+VesselReflectionData
[LOG 23:06:27.417] [F: 56999]: KWsrbGlobeVI collided into Launch Pad - relative velocity: 31.24613 - no impact momentum (no RB)
[LOG 23:06:27.418] KWsrbGlobeVI Exploded!! - blast awesomeness: 0.5
[LOG 23:06:27.420] [strutConnector]: Deactivated
[LOG 23:06:27.427] SSTUReflectionManager vesselCreated() : launchClamp1 (Vessel) :: KSPShaderTools.ReflectionManager+VesselReflectionData
[LOG 23:06:27.429] SSTUReflectionManager vesselCreated() : launchClamp1 (Vessel) :: KSPShaderTools.ReflectionManager+VesselReflectionData
[LOG 23:06:27.436] [KWsrbGlobeVI]: Deactivated
[LOG 23:06:27.466] 1 explosions created.
[LOG 23:06:27.567] Flight State Captured
[LOG 23:06:27.567] Saving Achievements Tree...
[LOG 23:06:27.568] Saving Achievements Tree...
[LOG 23:06:27.569] [MessageSystem] Save Messages
[LOG 23:06:27.678] Game State Saved to saves/ISS/persistent
[LOG 23:06:31.206] Packing Dream Chaser Cargo Debris for orbit
[LOG 23:06:31.230] Unpacking Dream Chaser Cargo Debris
[WRN 23:06:38.834] [F: 57387]: Vessel Dream Chaser Cargo Debris crashed through terrain on Kerbin.
[LOG 23:06:38.836] KzProcFairingSide4 Exploded!! - blast awesomeness: 0.5
[LOG 23:06:38.837] [KzProcFairingSide4]: Deactivated 
shadowmage45 commented 7 years ago

Still haven't been able to reason through any potential causes of this conflict. Really isn't anything in the TU code that should muck about with physics or collisions.

Have a couple possible solutions to implement though that could alleviate any 'vessel' related problems -- only have one RP in the scene, ever; constrain it to follow the FI.ActiveVessel, so it should still affect the currently controlled vessel properly, but will ignore any non-controlled vessels (non-controlled vessels will get their reflection-probe data from the same probe as the controlled vessel; meaning their reflections will be noticeably misplaced, but the distance of the uncrontrolled vessel will likely make the visual impact minimal; box projection on the probe itself could further alleviate this distortion).

shadowmage45 commented 7 years ago

Can confirm the issue using the craft provided (thanks!). (I didn't get explosions, but stuff definitely flew all over the place from collider issues).

Investigating now, will update once I know more about what is going on.

Drakenexh commented 7 years ago

Because so far is the only incompatible mod reported, couldn't be easy just to ignore anything PF related? Or the mandatory check couldn't tell them apart?

shadowmage45 commented 7 years ago

I don't touch colliders at all, so realistically, there shouldn't be anything to ignore.

But this --

[F: 22220]: KzResizableFairingBaseRing collided into SSTUReflectionProbe

is telling me that there is some sort of collider, somewhere, added onto the reflection probe (maybe it is being added by PF itself?).

shadowmage45 commented 7 years ago

Huh, apparently Unity code is... a bit dumb. When I create the reflection probe, I also create a 'primitive sphere'. These all come, by default, with a primitive SphereCollider component. So, immediately after I create the sphere, I find and delete this collider.

Problem averted, right? That is what I thought.

But apparently I thought wrong. Unity decides to only delete that collider after a frame has passed; and in that one frame of time, explosions and hilarity ensue.

Changing from GameObject.Destroy() to GameObject.DestroyImmediate(), and the problem goes away. What fun it is to work with Unity (sarcasm).

Initial testing results in explosion-free decoupling (well, as explosion-free as it gets in KSP). Doing one more round of testing, and then will clean the code up and call it solved.

Thanks @Drakenexh for your help in tracking this one down.

Drakenexh commented 7 years ago

Sir you are a steely eyed missile man.

You welcome!