Rudolf Meier

[WIP] Kerbal Joint Reinforcement - Next

Recommended Posts

Posted (edited)

Kerbal Joint Reinforcement - Next

a new version of the known reinforcement mod we all use

 

The current version is good, but it's not yet the "Next" step. This one will follow soon.

 

Debug Version

There is a debug version available. It contains an additional gui to control KJRn and to show all the joints in the scene.

 

How To Get It

this mod is CKAN-Indexed-green.svg (only release versions)

Download: https://github.com/meirumeiru/Kerbal-Joint-Reinforcement/releases

Source: https://github.com/meirumeiru/Kerbal-Joint-Reinforcement

License: GPL-3.0

Kerbal Joint Reinforcement - Next

 

Info For Developers

Spoiler

To make your mod compatible with KJRn, you have to do nothing. It is enought to do the same that is needed to make it compatible with KSPs autostruts.

1) Every part that can move (like e.g. the Infernal Robotics servos) need to implement IJointLockState (this is an official KSP interface). The only function to implement is "bool IsJointUnlocked()". Simply return true when your joint can move and false when it cannot.

2) If your joint can change its ability from "locked" to "unlocked" and back, then you can call "CycleAllAutoStrut()" on the vessel to inform autostruts and KJRn that it should rebuild the extra joints/struts (and, depending on your returns, maybe also establish one accross your part).

 

special cases:

If you want to call CycleAllAutoStrut only on KJRn (for what reason ever), then you can do it using the following code.


Type KJRManagerType = null;

AssemblyLoader.loadedAssemblies.TypeOperation (t => {
	if(t.FullName == "KerbalJointReinforcement.KJRManager") { KJRManagerType = t; } });

if(KJRManagerType != null)
{
	object o = FlightGlobals.FindObjectOfType(KJRManagerType);
			
	if(o != null)
		KJRManagerType.GetMethod("CycleAllAutoStrut").Invoke(o, new object[] { vessel });
}

 

If you have a mod/part that is a moving part but you cannot implement IJointLockState in one of its modules, then you can also use the "KJRExcluded" module. Simply add this to the cfg file of your part.


MODULE
{
	name = KJRExcluded
}

 

.

Edited by Rudolf Meier

Share this post


Link to post
Share on other sites

Could you add the ModuleDockRotate and ModuleNodeRotate exemptions to your config.xml? They both extend ModuleBaseRotate, so if the exemption logic handles extensions you just have to add ModuleBaseRotate.

I know I can file a pull request, but I've been coding all the afternoon... :P

Share this post


Link to post
Share on other sites
55 minutes ago, peteletroll said:

Could you add the ModuleDockRotate and ModuleNodeRotate exemptions to your config.xml? They both extend ModuleBaseRotate, so if the exemption logic handles extensions you just have to add ModuleBaseRotate.

I know I can file a pull request, but I've been coding all the afternoon... :P

I will post information about how this has to be done. But there will be no exceptions like those you know from early KJR versions.

Share this post


Link to post
Share on other sites

A couple very technical questions:

1) Are extra KJR joints implemented as PartJoint or ConfigurableJoint?

2) In the case of NodeRotate parts, the PartModule that controls the PartJoint motion, and that implements IJointLockState, can be either on the Host or Target part of the PartJoint instance. So, in this vessel structure:

vessel root Part <- PartJoint <- part <- PartJoint <- ... <- target Part <- moving PartJoint <- host Part <- PartJoint <- ...

will both target Part and host Part need a IsJointUnlocked() that returns true, or one of them is enough, and which one?

... I hope I made myself clear...

... more questions...

3) Does KerbalJointReinforcement.KJRManager.CycleAllAutoStrut() call stock Vessel.CycleAllAutoStrut(), or do I have to call it myself right before, or after?

4) Where and when exactly do I have to call AssemblyLoader.loadedAssemblies.TypeOperation()?

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, peteletroll said:

1) Are extra KJR joints implemented as PartJoint or ConfigurableJoint?

ConfigurableJoint... I think the launch-clamp reinforcement uses FixedJoint at the moment. But in general it's ConfigurableJoint and I think that is what it will be always in the future.

1 hour ago, peteletroll said:

2) In the case of NodeRotate parts, the PartModule that controls the PartJoint motion, and that implements IJointLockState, can be either on the Host or Target part of the PartJoint instance. So, in this vessel structure:

vessel root Part <- PartJoint <- part <- PartJoint <- ... <- target Part <- moving PartJoint <- host Part <- PartJoint <- ...

will both target Part and host Part need a IsJointUnlocked() that returns true, or one of them is enough, and which one?

*um*... depends.

KJRn is doing it correctly and you only need to implement it on the moving Part.

But the autostruts of KSP have a bug (https://bugs.kerbalspaceprogram.com/issues/18356). Sometimes you need to do more to work around it. Or, simply don't use autostruts and use KJRn.

1 hour ago, peteletroll said:

3) Does KerbalJointReinforcement.KJRManager.CycleAllAutoStrut() call stock Vessel.CycleAllAutoStrut(), or do I have to call it myself right before, or after?

No, it does not call it. It doesn't matter if you call it before or after. I think most users won't use KJRn and autostruts together anyway.

1 hour ago, peteletroll said:

4) Where and when exactly do I have to call AssemblyLoader.loadedAssemblies.TypeOperation()?

Whenever you want. You can also do it in an initialization function (e.g. in the OnAwake).

Edited by Rudolf Meier

Share this post


Link to post
Share on other sites
Posted (edited)

May I install/uninstall KJRn whenever I want without affecting my saved games?

8 minutes ago, Rudolf Meier said:

KJRn is doing it correctly and you only need to implement it on the moving Part.

Is the moving part the host Part or the target Part? That is, the part farther from or closer to the root Part?

(sorry for being such a nitpick...)

Edited by peteletroll

Share this post


Link to post
Share on other sites
8 minutes ago, peteletroll said:

May I install/uninstall KJRn whenever I want without affecting my saved games?

yes

8 minutes ago, peteletroll said:

Is the moving part the host Part or the target Part? That is, the part farther from or closer to the root Part?

It's the part you are building. So, for Infernal Robotics for example it's the servo itself. If a part moves, then it moves itself. Often the static part of such constructs are just "illusions" ... like meshes that are not moved or are moved in the opposite direction so that the appear to be static.

Share this post


Link to post
Share on other sites
1 minute ago, Rudolf Meier said:

It's the part you are building.

OK, there's a basic difference between Infernal Robotics and DockRotate/NodeRotate: DR acts directly on the PartJoints between different parts. So, there's no "moving part", but there's a "moving joint between two parts". If a part's IsJointUnlocked() returns true, what are the KJRn joints that get disabled? 

Share this post


Link to post
Share on other sites
5 minutes ago, peteletroll said:

OK, there's a basic difference between Infernal Robotics and DockRotate/NodeRotate: DR acts directly on the PartJoints between different parts. So, there's no "moving part", but there's a "moving joint between two parts". If a part's IsJointUnlocked() returns true, what are the KJRn joints that get disabled? 

KJRn is building additional joints to a part from it's children, but never from it's parent and also not between the parents and the children of such a part.

Share this post


Link to post
Share on other sites

There is one concern with upcoming DLC. It would be hard to expect that SQUAD would check for KJRn existance and make a proper function calls before/after moving parts. That would probably need to be hardcoded within KJRn, to detect stock robotic movable parts and handle joints as necesasry.

I would not recommend to re-introduce XML config file for this, it would be clumsy to maintain on the long run as it was the case with original KJR code.

Share this post


Link to post
Share on other sites
30 minutes ago, kcs123 said:

There is one concern with upcoming DLC.

I'm working on solutions for that already since last year... I will show the first implementation for this soon... :) 

Share this post


Link to post
Share on other sites

First DockRotate/KJRNext tests are successful. Expect release soon™.

Share this post


Link to post
Share on other sites
Posted (edited)
On ‎5‎/‎7‎/‎2019 at 8:28 PM, Rudolf Meier said:

I'm working on solutions for that already since last year... I will show the first implementation for this soon... :) 

the way these guys messed up the situation really rips my nerves

Edit: "these guys" -> Squad / the makers of KSP // "the situation" -> how KSP works internally

Edited by Rudolf Meier

Share this post


Link to post
Share on other sites
Posted (edited)
6 hours ago, Rudolf Meier said:

the way these guys messed up the situation really rips my nerves

Who?

 

Also a question. Does offsetting parts from there initial attach location affect joint strength? Thanks!

Edited by Svm420

Share this post


Link to post
Share on other sites
7 hours ago, Svm420 said:

Who?

Squad :) ... they are loading parts and ships in a way that is super difficult to understand. It seems to be a constant load and reload, compile and recompile ... They are sort of shooting events on a system and try to solve them all "somehow" ... there is no defined order of execution. If something takes longer to load this time, it's done like this, otherwise completely different and in the end we hope that the result ist still correct... that's ... super difficult to follow.

Share this post


Link to post
Share on other sites
7 hours ago, Svm420 said:

Also a question. Does offsetting parts from there initial attach location affect joint strength? Thanks!

Short: I don't think so.

Longer: I would say yes... as far as I understand the systems behind it and still remember what I read about it, I would say, that it is affecting it. But only because of the angle between the different joints. ... I guess that this can affect the solver. But just a tiny bit...

... in the end, I guess, until we have measured this, we don't know it. :)

And... measuring... I'm working on that, so that we get more data.

Share this post


Link to post
Share on other sites
18 minutes ago, Rudolf Meier said:

And... measuring... I'm working on that, so that we get more data.

Speaking of data ... Does latest release include KJR autostrut visualisation, if so, how to enable it ? Stock debug menu only shows stock autostruts.
Haven't encountered any issues yet, though not being playing much either.

Share this post


Link to post
Share on other sites
Posted (edited)
30 minutes ago, kcs123 said:

Speaking of data ... Does latest release include KJR autostrut visualisation, if so, how to enable it ? Stock debug menu only shows stock autostruts.
Haven't encountered any issues yet, though not being playing much either.

Yes, it does...

First you can only see the different joints, in a next version I'm planning to colorize the joints according to their instability. Like this it would be (in flight) possible to see which joint was the one that had the biggest deformation.

Edited by Rudolf Meier

Share this post


Link to post
Share on other sites

I've uploaded the latest version... it's not yet on CKAN, but for all those who want to try it, download it from Github. The debug version is now also online.

Share this post


Link to post
Share on other sites
1 hour ago, Rudolf Meier said:

Yes, it does...

First you can only see the different joints, in a next version I'm planning to colorize the joints according to their instability. Like this it would be (in flight) possible to see which joint was the one that had the biggest deformation. 

How to enable visualisation ? Does it require some changes in config file or it is in some hidden menu ?

Share this post


Link to post
Share on other sites
Just now, kcs123 said:

How to enable visualisation ? Does it require some changes in config file or it is in some hidden menu ?

When installed, there should be a "KJR" button on the right side when in flight. (only in debug version)

Share this post


Link to post
Share on other sites

*hmm* ... I'm not sure, but maybe the new version has a time warp problem ...

Share this post


Link to post
Share on other sites
26 minutes ago, Rudolf Meier said:

*hmm* ... I'm not sure, but maybe the new version has a time warp problem ...

yes it had...

I have deleted it and re-uploaded it (same version number) ... it is better now

Share this post


Link to post
Share on other sites

I've uploaded 4.0.3 (almost the same as 4.0.2 except for the debug version) ... and this time it's also released on CKAN

Share this post


Link to post
Share on other sites
Posted (edited)

Alright, I put in the development build and tested it out.

The stutter happens on all craft. Even with the development build having all options turned off, it still stutters.

If I uninstall KJRn, the stuttering goes away. I'm wondering if it's memory related. I'm not quite full, but 10/12GB of ram being used.

I did see an error when loading a certain craft.

"Vessel SENTINEL was not loaded because it had the following parts missing: KJRAutoStrutHelper"

I've never installed Autostrut, I've got all the options currently disabled.

Which seems to happen upon exiting a vessel, not entering. It loads in the new vessel, but complains about the previous vessel not loading, but it did load.

Edited by Paadwyn

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now