-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make mobility links into objects, also fix to obscure gearbox bug
What it says on the tin, making a step into a mobility rewrite more accessible As of right now they still function the same as before, but they are more centralized and at least a little bit easier to understand; these have accessor functions to modify certain parts of the links as well as obtain them Eventually it might be a good idea to solely use these to transfer torque throughout the drivetrain as opposed to doing it per gearbox, and these have debugoverlay drawings to represent that transfer Also a sort of bandaid fix for a bigger issue when it comes to splitting power from an engine to multiple gearboxes, only to then rejoin them afterwards to one wheel
- Loading branch information
1 parent
5834296
commit 54b5b63
Showing
3 changed files
with
77 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
local ACF = ACF | ||
local Meta = {} | ||
local String = "Link [Source = %s, Target = %s, Origin = %s, Axis = %s]" | ||
local Debug = ACF.Debug | ||
local Objects = ACF.Mobility.Objects | ||
|
||
function Objects.Link(Source, Target) | ||
local Link = { | ||
Vel = 0, | ||
ReqTq = 0, | ||
|
||
Source = Source, | ||
Target = Target, | ||
Origin = Vector(), | ||
TargetPos = Vector(), | ||
Axis = Vector(1, 0, 0), | ||
IsGearbox = Target.IsACFGearbox or false | ||
} | ||
|
||
setmetatable(Link, Meta) | ||
|
||
return Link | ||
end | ||
|
||
local red = Color(255, 0, 0) | ||
local orange = Color(255, 127, 0) | ||
function Meta:Transfer( Torque ) | ||
local P1 = self.Source:LocalToWorld(self.Origin) | ||
local P2 = self.Target:LocalToWorld(self.TargetPos) | ||
Debug.Line(P1, P2, 0.05, self.IsGearbox and red or orange, true) | ||
Debug.Text(LerpVector(0.5, P1, P2), math.Round(Torque, 1) .. " Nm", 0.05, false) | ||
|
||
|
||
end | ||
|
||
function Meta:ToString() | ||
return String:format(self.Source, self.Target, self.Origin, self.Axis) | ||
end | ||
|
||
AccessorFunc(Meta, "Source", "Source") | ||
AccessorFunc(Meta, "Target", "Target") | ||
AccessorFunc(Meta, "Origin", "Origin", FORCE_VECTOR) | ||
AccessorFunc(Meta, "Axis", "Axis", FORCE_VECTOR) | ||
AccessorFunc(Meta, "TargetPos", "TargetPos", FORCE_VECTOR) | ||
|
||
Meta.__index = Meta | ||
Meta.__tostring = Meta.ToString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters