Jump to content

Experimental CustomComponent System


photo

Recommended Posts

Hey,

Here I will write my suggestions about the new Component System. One post for suggestion in this topic :) I think that new Component System is a very big step in  general :)

Cheers,

Jan

Link to comment

I think that Component System should not enable Game and Physics in Editor by default. Please remove it at all or make it just for Game mode in ComponentSystem::init() for e.g. like that:

	if (!Editor::get()->isLoaded())
	{
		Game::get()->setEnabled(1);
		Physics::get()->setEnabled(1);
	}

 

Link to comment

It could be usefull to have an marker, icon or differences in some other color properties (individual one from properties file, not necessary whole properties file, because you can mix generated and created by user ) created by Component System.

Link to comment

There should be some easy way to regenerate properties file. This may be useful when you want to change initialization param or when you add, delete or modify properties in Component class by PROPERTY_PARAMETER macro.

Link to comment

Because components are initialized in order how they are added to node, there should be option in Editor2 to reorder them.

Link to comment

It would be nice to have possibility to add human readable label (titles) names for properties specified by PROPERTY_PARAMETER macro.

Edited by Klimczak.Jan
Link to comment

You can think to implement dependency of other components to create a new one, to add some validation that you can add some component only if you have other one (specified by you).

edit: this is possible to implement via ComponentSystem API, but such functionality at framework level could be very useful :)

Edited by Klimczak.Jan
Link to comment

Please add possibility to add array or lists of property values. There is many case where it is necessary to use it :)

Link to comment

I am not sure, but as I mind the Switch property is only defined to read values from property file. So we are able to create such property file via PROPERTY_PARAMETER macro, but then we need to manual edit generated property file to add switch values. So there could be useful to add possibility to create Switch param with values via code too.

Link to comment

I have some idea to check all defined variables by PROPERTY_PARAMETER macro if they are NULL, and if they are then automatically disable such component. This will prevent Editor from crash for Node property which are NULLED initially. Of course you can code own validation logic, but I think that such may be done automatically.

Link to comment

setEnabled(0);

void init() {
	setEnabled(0);
}

This should stop executing update() function. But when you add new Component into scent then update() function is once executed. This create a few problem to work with it.

Link to comment

You should check using nodes within Node References where in many cases it crash Editor. In general it is not working within Node References.

For e.g. please read next post.

Edited by Klimczak.Jan
Link to comment

When I select Node Reference in Asset Browser then it is initialized (executed init() from components within this Node Reference). It should do that until such node is added to a world OR there should be possibility to decide if will do like that or not.

There is some strength think that it adds DummyNode not managed by Editor which crash Editor like that:
image.thumb.png.9eb5d48bdcb7cc5e349bc1e83de80d81.png

where component is as easy as:

header file:

#pragma once

#include "ComponentSystem.h"
#include <UnigineEditor.h>

class TestComponent : public ComponentBase
{
public:
	TestComponent(const NodePtr &node, int num) : ComponentBase(node, num) {}
	virtual ~TestComponent() {}

	UNIGINE_INLINE static const char* getPropertyName() { return "test_component"; }

protected:
	void init() override;
	void update() override;
};
  
source file:
  
#include "TestComponent.h"

void TestComponent::init()
{
	Log::message("TestComponent: Zainicjalizowano komponent. \n");
}

void TestComponent::update() {}
  

I attach scene files.

Also when I add such Node Reference into scene it adds multiple instances of it (some of them as node references and some of them as individual objects which I select in Editor they are cloned as well. But after save and reload world there is just one Node Reference instance.

 

component_crash.world

component_crash.world.meta

test_comp.node

test_comp.node.meta

kolo.fbx

kolo.fbx.meta

TestComponent.cpp

TestComponent.h

Edited by Klimczak.Jan
Link to comment

It's looks like (Node)->findNode("xxx") not working in init() of component which is executed at Apply changes to Node Reference by editor. At the apply stage it returns NULL which may crash Editor in the case e.g.:

void TestComponent::init()
{
	NodePtr n = node->findNode("test", 1);
	n->setParent(node);
}

where it will crash Editor at line n-> because n will be NULLED only at Apply changes of Node References in Editor.

Edited by Klimczak.Jan
Link to comment

When you remove components from Editor then it constantly crash Editor at random situations (in engine update() loop) - when you have a few components added to it. Of course it may be my fault, but I don't have source code (yet) to verify and confirm it. But it will be good if you will look at that ;)

Edited by Klimczak.Jan
Link to comment

In general Component System it's GREAT IMPROVEMENT :) When it will be at release state, not experimental one it will be so useful :) Congrats for it !!!

Link to comment

There is also problem with cloning nodes which contains Components. Sometimes it's crashes Editor or cloned nodes disappears after world reload.

Link to comment

Hello Jan,

thanks for feedback! 

Quote

I think that Component System should not enable Game and Physics in Editor by default

Yes, we have this planned. Actually, this is the reason of crashes you'd reported here.

On 07.05.2018 at 5:52 PM, Klimczak.Jan said:

I am not sure, but as I mind the Switch property is only defined to read values from property file. So we are able to create such property file via PROPERTY_PARAMETER macro, but then we need to manual edit generated property file to add switch values. So there could be useful to add possibility to create Switch param with values via code too.

Yes, it should be useful, but for now we thought of manual xml editing as an essential part of working with properties.

On 07.05.2018 at 6:34 PM, Klimczak.Jan said:

I have some idea to check all defined variables by PROPERTY_PARAMETER macro if they are NULL, and if they are then automatically disable such component. This will prevent Editor from crash for Node property which are NULLED initially. Of course you can code own validation logic, but I think that such may be done automatically.

You can try adding in CS.cpp the following line:

ComponentSystem::get()->setWarningLevel(ComponentSystem::WARNING_LEVEL::HIGH);

this will generate a number of warnings in log so it should be easier to find the issue.

On 07.05.2018 at 7:42 PM, Klimczak.Jan said:

setEnabled(0);

Already fixed this :)

Jan, thanks again for feedback. It took some time to handle :)

I've posted all your suggestions to our tracker. Component system is still in development and will be improved step-by-step.

  • Like 1

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Hello Morbid,

Thank you for your answer :) I will use your suggestions. Component system is great! I am already use it and I want to help you to release it as production ready system that's why I would like to help test it for you and share with my feedback ... 

  • Like 1
Link to comment
×
×
  • Create New...