I’m new to Unreal Engine, so forgive me if this is a silly question.
I’m trying to call (), so under the IWYU paradigm I need to include a header file reference where () is defined. There appears to be three places where () is defined:
So am I right in saying that the reason () can be found in different places, is because these functions override the () virtual function defined in UObject, and provide three different methods of returning the same pointer to the world? The methods may be different because they can return that pointer in different ways, but as it’s the same result, it doesn’t really matter which header file I include if the code compiles and works.
() return world which that object belongs to, and each object have different sense of it, if it belongs at all to the world. So the override ().
One of actor main function is to beling to the world (when world gets destroyed all actors goes with it) and one of UWorld function is to keep track of actors.
Components inherently also belongs to world (but AActor keeps track of them not UWorld) because they are part of Actor so it returns world of host actor they are in.
As for why UWorld has it… well i was suppriced myself so i checked the source and find this note:
UWorld* UWorld::() const
{
// Arg... rather hacky, but it seems conceptually ok because the object passed in should be able to fetch the
// non-const world it's part of. That's not a mutable action (normally) on the object, as we haven't changed
// anything.
return const_cast<UWorld*>(this);
}
Note that it just return casted this as kind of expected. Note that those aren ot only function declerting own