Critical issue with StaticMesh class [4.8P3+]

There is a critical issue with current 4.8 Preview 3+ when trying to create class based on StaticMesh.
Steps to reproduce:

  1. Download actual 4.8 sources from github. Compile it (VS2013, dev. editor, Win64, all by default)
  2. Run editor. Create C++ project->Basic code (template doesn’t matter, I suppose).
  3. Restart editor, compile UE4Editor-TestProject if message box appears.
  4. File->New C++ class, check “Show all classes” and select StaticMesh. Next. Name it, lets say, SMTeleport, Create Class. Editor will try to compile it. It will fail. Now switch to opened Visual Studio and try to compile it by youself. And you will get:

Error 4 error C4150: deletion of pointer to incomplete type ‘FStaticMeshRenderData’; no destructor called C:\DevProjects-Games\UE4_v48\Engine\Source\Runtime\Core\Public\Templates\ScopedPointer.h 40 1 TestProject

Error 5 error C4150: deletion of pointer to incomplete type ‘FStaticMeshRenderData’; no destructor called C:\DevProjects-Games\UE4_v48\Engine\Source\Runtime\Core\Public\Templates\ScopedPointer.h 40 1 TestProject

Visual Studio points me here:

/** Destructor. */
~TScopedPointer()
{
	delete Reference; <--- here.
	Reference = nullptr;
}

Please, fix it as soon as possible.

Why are you sub-classing UStaticMesh?

Well, why not? :slight_smile:

I just create C++ class via Editor, and it offer me (after I check “Show All Classes”) to sub-class StaticMesh. As a result in Visual Studio I have my newly created class which is sub-classing UStaticMesh.

If UStaticMesh shouldn’t be sub-classed, then why it listed in “Show All Classes”?

Anyway, there is not much to sub-class - since you even cannot compile it just after you created class from StaticMesh via editor. Or may be there is should be something additionally added to generated cpp/h files so it can at least compile?

Hey Krakean-

What are you trying to use the Static Mesh subclass for? If you’re trying to add functionality for a teleporter you’ve created it may be better to use an actor or a static mesh component that can be added to an actor blueprint instead. Subclassing the Static Mesh would mean that you’re trying to add code directly to the mesh rather than using the mesh to represent something else that uses the code. Let me know if that helps at all.

Cheers

Hi, .
Well, I trying to create a simple Teleport object, which can be placed in editor by level designer and where this level designer can specify, in Teleport’s details window, to which another teleport object a player should be teleported when player enters this, uhm, teleport.

I didn’t found in C++ documentation anything what can help me to solve this issue, at least in terms of what class my object should sub-class in such case (pawn? actor? actor component? scene component? staticmesh?).

Plus, I’m not much interested in blueprints, I prefer to create as much as possible via C++. At least my project is multiplayer-only and will contain several maps, so I want to all common things to be done in C++, and only those which are unique for some levels - in blueprints.

Your best bet would be to create an Actor subclass with the functionality of the teleporter you want. Exposing a pointer of the teleporter class in code will allow the designer to pick other teleporters placed in the editor as the return point. Using a StaticMeshComponent pointer in code will allow you to set what mesh you’d like to use to represent the teleporter while the functionality remains on the actor.

Thanks, . I will try it. But still, may be then “StaticMesh” should be removed from “Show All Classes” list, if it cannot be used since even simple sub-classing from it produces inability to compile?

No - it’s possible to subclass it, but the logic for generating the sub-classed file can’t deal with all the constraints of C++, it just makes a best guess. There are sometimes files you need to manually include at the top of your files/PCH in order to compile that it can’t automatically figure out right now. In this case you’re likely missing StaticMeshResources.h which is where FStaticMeshRenderData is defined.