Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
TWEAKSCALEEXPONENTS
{
name = ModuleSimpleAdjustableFairing
segmentLength = 1
scale = 1
deploySpeed = 1
shieldingCenter = 1
shieldingBaseRadius = 1
editorOpenOffset = 1
}
4 changes: 2 additions & 2 deletions SimpleAdjustableFairings/ModelData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ObjectNotFoundException(string name) : base($"No object named {name} coul
[Persistent]
public bool enabled = true;

public ResolvedModelData Resolve(GameObject lookupRoot)
public ResolvedModelData Resolve(GameObject lookupRoot, float scale)
{
if (!enabled) return null;

Expand All @@ -50,7 +50,7 @@ public ResolvedModelData Resolve(GameObject lookupRoot)

if (prefab == null) throw new ObjectNotFoundException(transformName);

return new ResolvedModelData(prefab, mass, CoM, rootOffset);
return new ResolvedModelData(prefab, mass * scale * scale, CoM * scale, rootOffset * scale);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually hmm, why is multiplying the rootOffset by scale necessary? Shouldn't it not matter since TweakScale adjusts the whole model?

}
}

Expand Down
28 changes: 24 additions & 4 deletions SimpleAdjustableFairings/ModuleSimpleAdjustableFairing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public class ModuleSimpleAdjustableFairing : PartModule, IScalarModule, IPartCoM
private bool needsRecalculateDragCubes;
private bool needsNotifyFARToRevoxelize;

private float fairingScale = 1.0f;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like weird indentation here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I used tabs for intendation, as I got used to it. Sorry for breaking code conventions.


#endregion

#region Properties
Expand Down Expand Up @@ -173,6 +175,24 @@ public void ModuleDataChanged(BaseEventDetails details)
[KSPEvent]
public void FarWasNotifiedToRevoxelize() => needsNotifyFARToRevoxelize = false;

[KSPEvent]
void OnPartScaleChanged(BaseEventDetails data)
{
fairingScale = data.Get<float>("factorAbsolute");

if (!FindTransforms()) return;

// Not yet initialized
if (fairingRoot == null) return;

SetupFairing();

NotifyFARToRevoxelize();
RecalculateDragCubes();

IgnoreColliders();
}

#endregion

#region Actions
Expand Down Expand Up @@ -434,7 +454,7 @@ private bool FindTransforms()
{
try
{
wallBaseObjectPrefab = wallBaseData.Resolve(modelRoot);
wallBaseObjectPrefab = wallBaseData.Resolve(modelRoot, fairingScale);
}
catch (ModelData.ResolveException ex)
{
Expand All @@ -447,7 +467,7 @@ private bool FindTransforms()
{
try
{
wallObjectPrefab = wallData.Resolve(modelRoot);
wallObjectPrefab = wallData.Resolve(modelRoot, fairingScale);
}
catch (ModelData.ResolveException ex)
{
Expand All @@ -460,7 +480,7 @@ private bool FindTransforms()
{
try
{
capObjectPrefab = capData.Resolve(modelRoot);
capObjectPrefab = capData.Resolve(modelRoot, fairingScale);
}
catch (ModelData.ResolveException ex)
{
Expand All @@ -483,7 +503,7 @@ private bool FindTransforms()
{
try
{
coneObjectPrefab = coneData.Resolve(modelRoot);
coneObjectPrefab = coneData.Resolve(modelRoot, fairingScale);
}
catch (ModelData.ResolveException ex)
{
Expand Down