Viewport measure tool - modifying engine c++ code to convert cm to meters

Hello,
UE has a nifty measure tool that you can middle mouse drag in the orthographic viewport to show distances. I’d like to modify this to show meters.
This would give a an opportunity to learn how to modify small parts of the engine via c++.
Can some of the more experience lecturers of GDtv help point me in the right direction.

Thanking you,
behram

Hi Behram,
The units are sort of key throughout unreal and always cm Changing the engine to show/use metres could possibly break any of the plugins not part of the engine. That’s not to say it isn’t possible but since the conversion is simple, wouldn’t it be better just to work it out in your head?

If you’re determined to make changes to the engine, make sure you back up before modifying just in case. The engine itself can take several hours (depending on your hardware) to build when modifying so also be aware of this. Also, every time a new version is released, you’d have to migrate your modifications.

1 Like

This is already a feature within the editor preferences

image

1 Like

Thank you beegeedee. Totally understand understand your advise. I can easily create a BP to do this but I want to learn how to modify the engine code. I may even find a way to extend the class that implements the line draw function.
I miss hacking on Unity (which I learned thanks to Bens udemy courses ) . I figure if i dont start to try and tinker with engine code I will never ever gain proficiency with UE c++ .

I’m looking for guidance on how i’d go the process.
Questions like where
1.would I even start to search in the engine code base
2. Is it even mentioned in the documentation
I also understand that the focus of this forum should be (and is ) on the c++ wrt the tutorials coverd and not modifying / hacking on engine code. But i’m ‘struggling’ to learn how to make UE do what i want .

I miss unity so much…
b

Thank you Dan.
I found this forum thread on the topic.
https://answers.unrealengine.com/questions/553137/view.html
But it works after I followed your tip (to adjust it in the preferences instead). Cheers

Once again I am trying to learn how to work / hack my way out of things when there are no in engine answers. I had a similar experience when using 4.25 virtual camera system on the iPad. In the apps settings there was a drop down to allow for input to come from other tracking sources (vs the ipads inbuilt tracking ). However this just didnt work . The option may have only been a stub function to allow for the developer to write his own. Eventually I had to wait it out for 4.26 . I dont want to keep being in those situations hence the investment in UE C++.

It’s damn hard but i want to take small steps towards proficiency. I hope Ben or Sam release a course on making plugins and extending the engine . Have been nagging them to do this from their UE c++ Kickstarter days :slight_smile:

behram

update 1
I gave Orfeasel a ping (do read his C++ tutorials page )

He helped me source this :
MeasureDistanceSampleTool.h
and
MeasureDistanceSampleTool.cpp

By golly ! that’s a lot to take in :sweat_smile:
Guess I know what i’m going o be doing the whole month. If anyone wants to learn this together hmu.

Cheers,
b

Ok I managed to source the engine code that handles the measure functionality.
https://docs.unrealengine.com/4.26/en-US/API/Editor/UnrealEd/FDragTool_Measure/
I need a little help in getting this to work.

  1. I create a UE c++ project and create a simple class
  2. on opening VS studio I open the cpp file and make changes to the code below ( set Divisor to 30.0f instead 100.0f )
  3. Where do I go from here ? Do i just hit rebuild or do i have to rebuild the whole engine

Thanks,
b

switch (GetDefault<ULevelEditorViewportSettings>()->MeasuringToolUnits)
		{
		case MeasureUnits_Meters:
			Divisor = 30.0f; // Original code  Divisor = 100.0f;
			// Max one decimal place allowed for meters.
			DecimalPlaces = FMath::Clamp(FMath::FloorToInt(1.5f - OrderOfMagnitude), 0, 1);
			break;

If it’s part of the UE4 project then you just need to build that.

Thanks Dan,
Changing the code above in a regular cpp project using the editor that ships with the launcher didnt work.

I rebuilt the engine and changed the code above to get it to work. i.e I now have a custom editor that reflects these changes.

Cheers,
b

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.