Skip to content

Ungleichmäßige Fahrgassen #3

Description

@webalizer-gt

Zum Thema ungleichmäßige Fruchtenfernung ist mir eingefallen, dass dural damals im MR-Mod auch schon damit gekämpft hat. Er hat z.B. bei Schneidwerken "live" die workAreas verändert.
Vielleicht lohnt es sich, das einfach mal mit den workAreas der Fahrgassen auszuprobieren?
Hier die Codes:

  1. Aufruf innerhalb update() in cutter.lua:
    RealisticCutter.realCuttingAreasCorrection(self);

  2. Funktion in cutter.lua:

function RealisticCutter.realCuttingAreasCorrection(self)
	local i = 1;
	for k, cuttingArea in pairs(self.cuttingAreas) do
		RealisticUtils.realAreaCorrection(self, cuttingArea, self.realGenCuttingAreas[i]);
		i = i + 1;
	end;
end;
  1. Die eigentliche Funktion:
function RealisticUtils.realAreaCorrection(self, area, genuineArea, maxCorrection)

	if RealisticGlobalListener.AREA_CORRECTION_ENABLED then

		--******************* DURAL ******************************************
		-- i observe that cuttingarea alignment was wrong depending on y world rotation of the tool
		-- if we take the world x axis as 90� axis, and the world z axis as 0� axis, then the alignment of cuttingareas is perfect when the world y rotation of the tool is 45� or -135�
		-- the baddest is when the world y rotation is 135� or -45�
		-- don't ask why the max correction is 40cm.. i don't know (think it has to be with terrain "tile" size and shape or something like that...) => maybe it as to be with "cellSize" in map.i3d (usually, this value is 8)

		local rotX, rotY, rotZ = getWorldRotation(area.start);
		local x,y,z = localDirectionToWorld(area.start, 0, 1, 1);
		local correction = 0;
		local angle45rad = 0.25*math.pi;
		
		if maxCorrection==nil then
			maxCorrection = RealisticGlobalListener.AREA_MAX_CORRECTION;
		end;
		
		if y<0 then -- for plough
			rotY = -rotY;
		end;
		
		local diffAngle = angle45rad - rotY;
		if z<0 then
			diffAngle = angle45rad + rotY;
		end;
		
		correction = - maxCorrection * math.abs(math.sin(diffAngle));
		
		if rotY>angle45rad or (z<0 and rotY>-angle45rad) then
			correction = -correction;
		end;
		
		if y<0 then -- for plough
			correction = -correction;
		end;		
		
		--print("RealisticTool : rotY : " .. rotY .. " | z : " .. z .. " | y : " .. y .. " | correction : " .. correction);

		setTranslation(area.start, genuineArea.start.x + correction, genuineArea.start.y, genuineArea.start.z);
		setTranslation(area.width, genuineArea.width.x + correction, genuineArea.width.y, genuineArea.width.z);
		setTranslation(area.height, genuineArea.height.x + correction, genuineArea.height.y, genuineArea.height.z);
	end;	
end;

Zu finden ist das im mr-mod in folgenden Dateien:
RealisticCutter.lua
RealisticUtils.lua

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions