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

BDA collision detection currently has the same issue as an older version of KSP, fix inside: #56

Open
allmhuran opened this issue Jan 24, 2017 · 2 comments

Comments

@allmhuran
Copy link

allmhuran commented Jan 24, 2017

Reference this thread on the KSP forum from about a year ago http://forum.kerbalspaceprogram.com/index.php?/topic/121017-thermal-mechanics-and-physicssignificance/#comment-2478242

I can't remember which version of KSP it was at the time, but NK confirmed in that thread that when raycasts were used by engine exhaust to determine where heat should be applied, it was being applied to the wrong part if the actual "hit" part was physicsless.

BD Armory currently suffers exactly the same problem.

The issue is in pooledBullet.cs on line 254, specifically:

hitPart = Part.FromGO(hit.rigidbody.gameObject);

This causes a walk up the part tree to the first "physics" part.

However, the solution is to do exactly as NathanKell indicated in that forum thread... return the first actual part instead. And happily. code to do this correctly is also found in another file in BD Armory. The ModuleWeapon.cs implementation for lasers at line 1242 works as expected: if the laser actually hits a physicsless part then the following code correctly returns it:

Part p = hit.collider.gameObject.GetComponentInParent<Part>();

I have recompiled BD Armory on my machine, with the following single line change, which corrects the error. In pooledBullet.cs at line 254, remove

hitPart = Part.FromGO(hit.rigidbody.gameObject);

and replace it with

hitPart = hit.collider.gameObject.GetComponentInParent<Part>();

@allmhuran
Copy link
Author

allmhuran commented Jan 24, 2017

I should add: This will apply heat to the correct part, even if it is physicsless.

However, explosive weapons will also want to impart a force. No doubt this aspect of the code will want the actual physics part.

So I suggest using the hitPart = hit.collider.gameObject.GetComponentInParent<Part>(); code to determine where to apply heat, but the Part.FromGO(hit.rigidbody.gameObject); in order to determine where to apply force. Or, alternatively, simply apply heat to physicsless parts, but ignore force rather than pushing on the physics parent.

Specifically, this refers to lines 115 to 149 in explosionFX.cs. Right now, both heat and force require that the part have physics. However, it seems like the code could instead apply heat to parts regardless of physics, and force only if they have physics.

I can probably figure out how to make pull requests for each of these changes if you'd like. They're both really simple, and neither has any far-reaching consequences outside of the functions in which the change would be made.

@boomchacle
Copy link

Kinda off topic, but I think that BD's armory's explosion physics have an infinite amount of force. if you have many small objects with the same surface area of a larger one, they will be blown up with more force.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants