Call a C++ function through blueprints? / Update Mesh Distance Fields with origin shifting

So when making a new class, that same warning message and it points me to the output log for further info. It’s greek to me really but it seems like there is some sort of conflict, perhaps to do with the directory structure?:

Using 'git status' to determine working set for adaptive non-unity build (A:\Pavor\UnrealProjects\LandNav).
Creating makefile for LandNavEditor (no existing makefile)
Parsing headers for LandNavEditor
  Running UnrealHeaderTool "A:\Pavor\UnrealProjects\LandNav\LandNav.uproject" "A:\Pavor\UnrealProjects\LandNav\Intermediate\Build\Win64\LandNavEditor\Development\LandNavEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -abslog="C:\Users\Pavor\AppData\Local\UnrealBuildTool\Log_UHT.txt" -installed 
-FailIfGeneratedCodeChanges
ERROR: 'A:/Pavor/UnrealProjects/LandNav/Intermediate/Build/Win64/UE4Editor/Inc/LandNav/BlueprintFunctions.generated.h': Changes to generated code are not allowed - conflicts written to 'A:/Pavor/UnrealProjects/LandNav/Intermediate/Build/Win64/UE4Editor/Inc/LandNav/BlueprintFunctions.generated.h.conflict'
CompilerResultsLog: New page: Compilation - Aug 2, 2021, 10:49:07 AM
CompilerResultsLog: Using 'git status' to determine working set for adaptive non-unity build (A:\Pavor\UnrealProjects\LandNav).
CompilerResultsLog: Creating makefile for LandNavEditor (no existing makefile)
CompilerResultsLog: Parsing headers for LandNavEditor
CompilerResultsLog:   Running UnrealHeaderTool "A:\Pavor\UnrealProjects\LandNav\LandNav.uproject" "A:\Pavor\UnrealProjects\LandNav\Intermediate\Build\Win64\LandNavEditor\Development\LandNavEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -abslog="C:\Users\Pavor\AppData\Local\UnrealBuildTool\Log_
UHT.txt" -installed -FailIfGeneratedCodeChanges
CompilerResultsLog: ERROR: 'A:/Pavor/UnrealProjects/LandNav/Intermediate/Build/Win64/UE4Editor/Inc/LandNav/BlueprintFunctions.generated.h': Changes to generated code are not allowed - conflicts written to 'A:/Pavor/UnrealProjects/LandNav/Intermediate/Build/Win64/UE4Editor/Inc/LandNav/BlueprintFunctions.generated.h.conflict'

If you told it to make a new class with the exact same name, I imagine there would be a conflict.

Oh no, I added a number 2 haha. But this is the same warning it gave when creating the original class.

This is the generated CONFLICT file. I’ll take a look, maybe if can describe what exactly the issue is.

// Copyright Epic Games, Inc. All Rights Reserved.
/*===========================================================================
	Generated code exported from UnrealHeaderTool.
	DO NOT modify this manually! Edit the corresponding .h files instead!
===========================================================================*/

#include "UObject/ObjectMacros.h"
#include "UObject/ScriptMacros.h"

PRAGMA_DISABLE_DEPRECATION_WARNINGS
#ifdef LANDNAV_BlueprintFunctionLibrary2_generated_h
#error "BlueprintFunctionLibrary2.generated.h already included, missing '#pragma once' in BlueprintFunctionLibrary2.h"
#endif
#define LANDNAV_BlueprintFunctionLibrary2_generated_h

#define LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_SPARSE_DATA
#define LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_RPC_WRAPPERS
#define LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_RPC_WRAPPERS_NO_PURE_DECLS
#define LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_INCLASS_NO_PURE_DECLS \
private: \
	static void StaticRegisterNativesUBlueprintFunctionLibrary2(); \
	friend struct Z_Construct_UClass_UBlueprintFunctionLibrary2_Statics; \
public: \
	DECLARE_CLASS(UBlueprintFunctionLibrary2, UBlueprintFunctionLibrary, COMPILED_IN_FLAGS(0), CASTCLASS_None, TEXT("/Script/LandNav"), NO_API) \
	DECLARE_SERIALIZER(UBlueprintFunctionLibrary2)


#define LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_INCLASS \
private: \
	static void StaticRegisterNativesUBlueprintFunctionLibrary2(); \
	friend struct Z_Construct_UClass_UBlueprintFunctionLibrary2_Statics; \
public: \
	DECLARE_CLASS(UBlueprintFunctionLibrary2, UBlueprintFunctionLibrary, COMPILED_IN_FLAGS(0), CASTCLASS_None, TEXT("/Script/LandNav"), NO_API) \
	DECLARE_SERIALIZER(UBlueprintFunctionLibrary2)


#define LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_STANDARD_CONSTRUCTORS \
	/** Standard constructor, called after all reflected properties have been initialized */ \
	NO_API UBlueprintFunctionLibrary2(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()); \
	DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(UBlueprintFunctionLibrary2) \
	DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, UBlueprintFunctionLibrary2); \
DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER(UBlueprintFunctionLibrary2); \
private: \
	/** Private move- and copy-constructors, should never be used */ \
	NO_API UBlueprintFunctionLibrary2(UBlueprintFunctionLibrary2&&); \
	NO_API UBlueprintFunctionLibrary2(const UBlueprintFunctionLibrary2&); \
public:


#define LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_ENHANCED_CONSTRUCTORS \
	/** Standard constructor, called after all reflected properties have been initialized */ \
	NO_API UBlueprintFunctionLibrary2(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()) : Super(ObjectInitializer) { }; \
private: \
	/** Private move- and copy-constructors, should never be used */ \
	NO_API UBlueprintFunctionLibrary2(UBlueprintFunctionLibrary2&&); \
	NO_API UBlueprintFunctionLibrary2(const UBlueprintFunctionLibrary2&); \
public: \
	DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, UBlueprintFunctionLibrary2); \
DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER(UBlueprintFunctionLibrary2); \
	DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(UBlueprintFunctionLibrary2)


#define LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_PRIVATE_PROPERTY_OFFSET
#define LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_12_PROLOG
#define LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_GENERATED_BODY_LEGACY \
PRAGMA_DISABLE_DEPRECATION_WARNINGS \
public: \
	LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_PRIVATE_PROPERTY_OFFSET \
	LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_SPARSE_DATA \
	LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_RPC_WRAPPERS \
	LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_INCLASS \
	LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_STANDARD_CONSTRUCTORS \
public: \
PRAGMA_ENABLE_DEPRECATION_WARNINGS


#define LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_GENERATED_BODY \
PRAGMA_DISABLE_DEPRECATION_WARNINGS \
public: \
	LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_PRIVATE_PROPERTY_OFFSET \
	LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_SPARSE_DATA \
	LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_RPC_WRAPPERS_NO_PURE_DECLS \
	LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_INCLASS_NO_PURE_DECLS \
	LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h_15_ENHANCED_CONSTRUCTORS \
private: \
PRAGMA_ENABLE_DEPRECATION_WARNINGS


template<> LANDNAV_API UClass* StaticClass<class UBlueprintFunctionLibrary2>();

#undef CURRENT_FILE_ID
#define CURRENT_FILE_ID LandNav_Source_LandNav_Public_BlueprintFunctionLibrary2_h


PRAGMA_ENABLE_DEPRECATION_WARNINGS

I don’t think that will help at all. :frowning:

Im gonna make a new c++ project and then do all the same steps. I guess if that works, then we can at least say there is a difference between c++ project and a converted blueprint to c++.

Good idea.

Okay, creating a Blueprint Function Library class in a fresh C++ project produces these errors after building:

Severity Code Description Project File Line Suppression State
Error C2653 ‘UBlueprintFunctions’: is not a class or namespace name Test A:\Pavor\UnrealProjects\Test\Source\Test\MyBlueprintFunctionLibrary.cpp 6
Severity Code Description Project File Line Suppression State
Error MSB3073 The command C:\Program Files\Epic Games\UE_4.26\Engine\Build\BatchFiles\Build.bat TestEditor Win64 Development -Project=A:\Pavor\UnrealProjects\Test\Test.uproject -WaitMutex -FromMsBuild exited with code 6. Test C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets 45

I wonder…

that class that visual studio doesn’t think is a class - could it be that i would have to build unreal from source in order to access something like that? And that’s why it is missing?

You just need to substitute “UBlueprintFunctions” with “UMyBlueprintFunctionLibrary” in both code files. By changing the name of the class you broke a bit of the code.

1 Like

Hey, I got it working!

Back to the Blueprint to C++ project, I noticed that the C++ classes werent actually showing in the Content Browser. So I found this post:


… followed the steps, and it worked. Now I can call our function!

I guess it had something to do wiht the order that I did things with converting the project and then making a new class. I dont quite understand it but rebuilding the code that way seems like a pretty easy “unplug and plug back in” solution anyway for problems like this with folders not getting found for whatever reason.

Okay, all the ducks are in order, now to see if this is going to perform the job it’s meant to do!

It’s working.

:slight_smile:

Today you are the hero @NachoMonkey2 .

That is a lot of patient troubleshooting to offer for free! I hope this thread will help more people than just me figure this out if they need in the future.

1 Like

Wow! So, not only did the node appear, but the function actually worked? That’s great!

Thank you for your kind words. You were great to work with.

1 Like

Yeah, the function appeared as it should have. The problem there seemed to be related that my c++ classes were not loading into Unreal at all, hence not showing in the content browser.

Once that was taken care of, it worked exactly as expected. When I reset the origin, there is no change in the DFAO and my water shaders stay put.

There is a slight hiccup, but that is a minor tradeoff for the benefit gained. Just for reference, I have a 4km terrain with probably millions of foliage instances and they all are built with mesh distance fields. And the hiccup is like, a quarter second at most.

In order to hide the hiccup, I just call the origin shift less often. Rather than doing it every time performs a certain action, I just set it on a ten minute timer because I know player can only move so far in ten minutes.

It seems like it knew how to compile the C++ code, but didn’t know that it had to load the binaries.

Yeah, I expected the hiccup. The function literally iterates through all of the primitive components in your world. Perhaps instead of it being timed, you could perform it in preset zones? Then, you could have some sort of screen to hide it?

1 Like

yeah that is a good idea as well but will involve some setup. I probably work on that a little later.

I just tested on a packaged project for windows 64 and it seems to be working as well.

1 Like