Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple damage system #328

Merged
merged 17 commits into from
Dec 5, 2020
Merged

Simple damage system #328

merged 17 commits into from
Dec 5, 2020

Conversation

hbeni
Copy link
Collaborator

@hbeni hbeni commented Jun 2, 2020

Implemented a simple damage detection System (as foundation to #141):

  • Basic system ported over from c172p and adjusted coefficients accordingly to already present values (Systems/damage.xml)
  • Added a simple damage handler (Nasal/damage.nas) that informs the pilot via text of broken things.
    Now we could practice smooth landings without killing the front gear :)
  • Added a simple gui to aircraft dialog showing all damaged parts, so pilot can check it.
  • Damage should be stored over sessions when initializing "saved" state. This should be an easy one, just had no time to test this yet.
  • It has no effect on flight dynamics yet. This could easily achieved by integrating the damage values to the fcs calculations, like it's done in the c172p
  • gear should collapse; again this could be made easily by adjusting the z-pos of the contact points

As said in #141, model/graphical stuff etc. is to be done separately; Heiko already has some ideas for that.

  • Port that over to the C182T
  • when wings break, fuel should be leaked and the sensor break: small damage should make a leak, fully broken should set fuel to 0 and fail the sensor.

- code ported over from c172p and adjusted voefficients accordingly to already present values
- Added a simple damage handler (damage.nas) that informs the pilot via text of broken things.
  Now we could practice smooth landings without killing the front gear :)
- Added a simple gui showing all damaged parts, so pilot can check it.

TODOS:
- It has no effect on flight dynamics yet.
- Damage should be stored over sessions when initializing "saved" state.
@HHS81
Copy link
Owner

HHS81 commented Jun 2, 2020

@hbeni
Sorry, I`m busy with real life stuff- no corona holidays for me.

So, you are now going the c172p way? I wasn`t happy with this, since I experience a significiant lower fps with the c172p compared with the c182s.
Otherwise using the z-values of the contact points as suggested by you as damage indication (strength, affected systems) seems cheap.

@hbeni
Copy link
Collaborator Author

hbeni commented Jun 2, 2020

Hi Heiko, i had the FPS in mind and that was the reason i implemented it (like c172p) using jsbsim, which should be quite fast. Its really just some really small calculations this far.
Also i really wanted to train my landings :)

I think the hiccups you experienced came from the effects with the 3d stuff. I could not trace performance issues here so far; do you have any now with the branch?

Also, this was not soooo much of work so far, so if you have a better way and time to implement it, we can just easily throw away this implementation. Most of it is in damage.xml.

@stuartbuchanan
Copy link
Collaborator

Like Heiko, I'm not a huge fan of the c172p approach to adding very complex systems to what are fundamentally edge-cases and trying to model the impact of damage..

I think it's very good to notify the user when limits are exceeded that would damage the aircraft - wing G-loading, excess undercarriage loads, exceeding VNE.

However I'm less convinced about trying to model that damage either graphically or in the FDM. In my mind it is sufficient to simply provide a warning message to the screen. Some users will ignore this, others will be trying to fly within the envelope.

In terms of damage modeling itself:

  • Under excess loads, undercarriage on GA aircraft (microlights) tends to fail completely - the aircraft basically stops moving on the ground with a bent leg. So there's little point in trying to model the effects of this - the aircraft simply cannot move under it's own power.

I also don't think modeling damage to aircraft after they exceed Vne is accurate. As part of my annual check flight, my aircraft is flown as close to Vne as it can (e.g. steep dive, full power). So I do not think it would be damaged as soon as it exceeds it in any real way.

-Stuart

@hbeni
Copy link
Collaborator Author

hbeni commented Jun 2, 2020

The problem is to detect that some value was exceeded. This is the part which was modelled in jsbsim, because it is simple and fast there.
Currently there is a text expression in red when this happens.

I agree that we really don't need some fancy 3D modelling of damage for now (however that would add the public value of the simulator in my eyes), but i think it is very useful that the plane will not be flyable anymore when the wings broke (they don't do it straight out and well above the Vne value currently), as well as a collapsed gear - it gives immediate visual feedback to the pilot.

@HHS81
Copy link
Owner

HHS81 commented Jun 2, 2020

@hbeni @stuartbuchanan I am unsure, I like the way X-Plane handles it. Text messages are nice, but not realistic, as the real pilot has to find out himself what is going on. A bent leg or ruptured tyre won´t stop it within milliseconds, but will let the aircraft slide some time.
A overspeed of the flaps will make them loose, or bent the mechanism, so it can`t be retracted- asymmetrical lift is possible, and will make heavy problems. But sure- we should stay in a realistic envelope regarding damage. The flight manual gives already some hints what can happen (emergency procedures).

Unfortunately I don`t have much time for flightgear due to my master studies and teaching nursing students - I just keep watching the developement of FlightGear (plus having already an eye on a certain known british helicopter fgfs sim group taking things from my work under their name.... 😡 )
So I can only watch and help here and there with comments, not much developement time left, sadly.

@hbeni
Copy link
Collaborator Author

hbeni commented Jun 2, 2020

No worries. I donÄt think it is done in stone, but i think what we have here is better than nothing. We may come back and improve anytime.

@hbeni
Copy link
Collaborator Author

hbeni commented Jun 3, 2020

@HHS81

I like the way X-Plane handles it.

I don't know XPlane - how does it handle it?

@HHS81
Copy link
Owner

HHS81 commented Jun 5, 2020

@hbeni
As I could see, similar now like you now implemented. They feature overspeed of flaps, tyre damage, and engine damage on harder landings.
I will add some animations to the landing gears and see how I get the friction coefficient manipulated when gear is bent.

@hbeni
Copy link
Collaborator Author

hbeni commented Jun 5, 2020

Animations would be nice but please stay sharp on performance...
I think the performance got in the 172 comes from switching the 3d models.

@wlbragg
Copy link
Collaborator

wlbragg commented Jun 5, 2020

I think the performance got in the 172 comes from switching the 3d models.

That is right. It's almost entirely the extra mesh. The j3 was even worse as it had unnecessary 4kX4k textures. I think had I to do it all over from scratch, I would use shaders for the damage visuals. Something akin to wingflex.
As far as to do or not to do at all and peoples personal preferences. I think it is much more pleasing to see the results of messing up VS any message unless the message is "real time/real life" such as a stall warning siren or engine flame out. FDM changes due to structural failures if done with much planning could really enhance the simulation for emergency landing training and the likes. I think visualizing gear damage or collapse should be fundamental to a good simulation. It was even crudely built into the core. The approach I took was before I had gained much experience with modeling or FDM components and could be vastly improved on. But I feel it is most certainly value added to the simulation in general.
But then again I also believe we should finish the ground cover effects on the wheels and gears in the core code. All of these things were obviously at least thought about originally, or we wouldn't have some of the structure supporting these things, like ground cover hardness and friction values.
All the code I added for the ground effects (sinking and friction) had little noticeable impact on performance. But it made the gear change outs useful for something other than esthetics. Now the bush gears work on terrain where the stock gear doesn't and the skies work on snow where the default and bush gear don't. You can use floats and get a fairly realistic simulation. I personally like having that ability and realism.

Signed-off-by: Heiko Schulz <Heiko.H.Schulz@gmx.net>
@HHS81
Copy link
Owner

HHS81 commented Jun 5, 2020

No fps impact noticed so far- but only prop and gear done yet.

crashed

@hbeni
Copy link
Collaborator Author

hbeni commented Jun 6, 2020

Looks very good!
(Poor plane 😢)

@wlbragg
Copy link
Collaborator

wlbragg commented Jun 6, 2020

Looks good, if your into seeing your prop mangled, ha!

That is right. It's almost entirely the extra mesh. The j3 was even worse as it had unnecessary 4kX4k textures.

Now that I think about it, the first version of damage on the c172p was "more" expensive than the current version. The entire wing unit was one piece and required several duplicates of the entire wing bent in the different damage patterns. a set for left wing damage, right wing damage and both wings damage.
Similar to how the j3 still is. On top of this extra mesh were 4k textures.
cubdamage

I need to change the j3 to what we did to the c172p. I seperated the wing into 3 sections so I could simply change/duplicate one of the smaller sections. To improve on this would be to use a rotation instead of a new mesh. One better, shader magic.
c172pdamage

@hbeni
Copy link
Collaborator Author

hbeni commented Jun 8, 2020

@HHS81 Heiko, what do you think: The damage inspection GUI was introduced from me because i had the impression, damage will not be reflected in the model in the near timeframe.
With your work, i think it's obsolete and can be removed (at least when the wings are bent, too) :)

@wlbragg
Copy link
Collaborator

wlbragg commented Jun 8, 2020

FYI: I noticed you may be using a "repairing" flag to use for settling damage when resetting damage, similar to what the c172p does. Note an unresolved issue with the repairing flag and timer on "Airport Relocation" using the GUI.
See c172p-team/c172p#1325

@hbeni
Copy link
Collaborator Author

hbeni commented Jun 11, 2020

Oh god, it worked. Poor plane... Good that its so cheap to repair :)
I'm really thrilled how you will implement the broken wings 3D representation.

@HHS81
Copy link
Owner

HHS81 commented Jun 11, 2020

Nice, it never occurred to me to do that. Good idea!

I didn`t like the fact that you can fly through trees of a forest and still get up into the air. I don´t want to have a crash simulator, but also not an arcade game, where you get signalized "game over".
Especially in Nort America with all those little airports hidden in the woods, the perfect place for a C182.

@HHS81
Copy link
Owner

HHS81 commented Jun 11, 2020

@hbeni

Oh god, it worked. Poor plane... Good that its so cheap to repair :)
I'm really thrilled how you will implement the broken wings 3D representation.

First I want to find out, why the JSBsim structure points don´t recognize WOW. Then I will see...

@hbeni
Copy link
Collaborator Author

hbeni commented Oct 8, 2020

Hey Heiko,

First I want to find out, why the JSBsim structure points don´t recognize WOW.

i tried to figure out what exactly you are after, can you elaborate a bit so i can assist?

@stuartbuchanan
Copy link
Collaborator

stuartbuchanan commented Oct 12, 2020 via email

@hbeni
Copy link
Collaborator Author

hbeni commented Oct 13, 2020

Would it be possible to get the current regions average tree height (or even the tree height from the actual area) from the property tree? If so, we could easily make it dynamically.

@HHS81
Copy link
Owner

HHS81 commented Oct 13, 2020

@hbeni

Would it be possible to get the current regions average tree height (or even the tree height from the actual area) from the property tree? If so, we could easily make it dynamically.

Unfortunately not. They are not shown in the property tree, otherwise I would like have done it that way. 😞

@hbeni
Copy link
Collaborator Author

hbeni commented Oct 13, 2020

Should we open a FR ticket on fgfs core to get the property? :)

@HHS81
Copy link
Owner

HHS81 commented Oct 13, 2020

@stuartbuchanan

Damage < 90ft AGL assumes that all trees are that high. Looking through the regional material definitions, there are a lot of areas where the height of trees is significantly lower than 90ft: Here's a very rough distribution of heights: 10: 14 15: 24 20: 73 25: 63 30: 0 Obviously that is a count of regions, not the areas of the said regions. I suggest lowering the limit to (say) 50ft (~15m). That would ensure you are hitting the tree below the tree-tops (we generate some variation in the tree-top height as well), account for the c182 being high-wing, and the wing being strong enough to work as a leaf-strimmer for small branches! (Personally, I'm not a fan of complicated damage systems, and particularly the effort to animate a crashed aircraft. My experience IRL is that no-one wants to look at a crashed aircraft except the accident investigator and the engineer fixing it.)

-Stuart

Yes, that sounds like a good compromise.
I don´t want to have crash simulator as well. On the othe side, we claim to be a simulator and not an arcade game with "game over". But I would like to have an effect when as an example exceeding rwys - flying through the trees is too simple. I don`t want to go further, because I think it is enough for the user to hear the bang hitting the trees and loosing altittude with ending sitting on the ground. It shows people that the ability of the aircraft is limited.

@HHS81
Copy link
Owner

HHS81 commented Oct 13, 2020

Should we open a FR ticket on fgfs core to get the property? :)

You can do it if you want

@HHS81
Copy link
Owner

HHS81 commented Oct 13, 2020

Hey Heiko,

First I want to find out, why the JSBsim structure points don´t recognize WOW.

i tried to figure out what exactly you are after, can you elaborate a bit so i can assist?

I don´t get any WOW-signal of the structure points, when the gear is crashed

@hbeni
Copy link
Collaborator Author

hbeni commented Oct 14, 2020

Should we open a FR ticket on fgfs core to get the property? :)

You can do it if you want

done: https://sourceforge.net/p/flightgear/codetickets/2389/

@hbeni
Copy link
Collaborator Author

hbeni commented Oct 14, 2020

Yes, that sounds like a good compromise.

I think that too. The crash-feedback is extremely valuable tough, especially with the gear collapse we can train good landings.

@hbeni
Copy link
Collaborator Author

hbeni commented Oct 27, 2020

@HHS81 I tried it and can't reproduce (ie i get WOW contacts after crash) - is it this what you where looking after?

Screenshot_20201027_090139

@hbeni
Copy link
Collaborator Author

hbeni commented Oct 30, 2020

Just deteced that the C182T is broken with these additions. We need to port it over...

@hbeni
Copy link
Collaborator Author

hbeni commented Nov 4, 2020

So, i just ported missing bits to the C182T :)

@HHS81 Heiko, did my investigation above (#328 (comment)) help you already?

…l tank rupture spills all fuel and breakage of navlights/strobe)
@hbeni
Copy link
Collaborator Author

hbeni commented Nov 9, 2020

I just added a small enhancement: If the wings are damaged, fuel will leak out of the broken tank.
If the wing damage is severe (like ripping it off or collide with something), the whole fuel will be leaked instantly, and navlights/strobe will cease to work.

I think, the last thing missing here is the model showing the wing damage. the other stuff seems to work fine, both on the S and the T variant; i did plenty of test flights already.

@HHS81
Copy link
Owner

HHS81 commented Nov 11, 2020

I just added a small enhancement: If the wings are damaged, fuel will leak out of the broken tank.
If the wing damage is severe (like ripping it off or collide with something), the whole fuel will be leaked instantly, and navlights/strobe will cease to work.

I think, the last thing missing here is the model showing the wing damage. the other stuff seems to work fine, both on the S and the T variant; i did plenty of test flights already.

Hmm... the Cessna 182s has fuel bladders- I don`t think that fuel will leak with low wing damage.

@hbeni
Copy link
Collaborator Author

hbeni commented Nov 12, 2020

Hmm... the Cessna 182s has fuel bladders- I don`t think that fuel will leak with low wing damage.

Thanks for catching, i didn't know. The POH id not mention specifics :)
I fixed that.

Did my #328 (comment) help you?

@HHS81
Copy link
Owner

HHS81 commented Nov 21, 2020

Did my #328 (comment) help you?

Not really- but I guess I do know why it behaves like that. I think we can merge

@hbeni
Copy link
Collaborator Author

hbeni commented Nov 23, 2020

I think we can merge

@HHS81 should i, or do you want to do it yourself?

@HHS81 HHS81 merged commit bd3e9c6 into master Dec 5, 2020
@hbeni hbeni mentioned this pull request Dec 6, 2020
@hbeni hbeni deleted the damage branch January 20, 2022 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants