Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interfaces for easy expansion #2007

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/3d/Mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ class AX_DLL Mesh : public Object
std::vector<float> _spotLightUniformRangeInverseValues;

std::string _texFile;

// add by binxiaojiao
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments like this should not be added, since it doesn't add extra useful information to the code

public:
std::function<void()>& GetVisibleChanged() { return _visibleChanged; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should follow the convention used in Axmol, which is to use a lowercase first character, so it should be getVisibleChanged()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer public callback like engine callback renderer comnand

};

// end of 3d group
Expand Down
32 changes: 32 additions & 0 deletions core/base/Properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,38 @@ Properties* Properties::createNonRefCounted(std::string_view url)
return p;
}

Properties* Properties::createNonRefCounted(Data* data, ssize_t* dataIdx)
{
std::vector<std::string_view> namespacePath;

// data will be released automatically when 'data' goes out of scope
// so we pass data as weak pointer
Properties* properties = new Properties(data, dataIdx);
properties->resolveInheritance();

// Get the specified properties object.
Properties* p = getPropertiesFromNamespacePath(properties, namespacePath);
if (!p)
{
AXLOGWARN("Failed to load properties from mem.");
AX_SAFE_DELETE(properties);
return nullptr;
}

// If the loaded properties object is not the root namespace,
// then we have to clone it and delete the root namespace
// so that we don't leak memory.
if (p != properties)
{
p = p->clone();
AX_SAFE_DELETE(properties);
}
// XXX
// p->setDirectoryPath(FileSystem::getDirectoryName(fileString));
p->setDirectoryPath("");
return p;
}

static bool isVariable(const char* str, char* outName, size_t outSize)
{
size_t len = strlen(str);
Expand Down
2 changes: 2 additions & 0 deletions core/base/Properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ class AX_DLL Properties
* @script{create}
*/
static Properties* createNonRefCounted(std::string_view url);
// add by binxiaojiao
static Properties* createNonRefCounted(Data* data, ssize_t* dataIdx);

/**
* Destructor.
Expand Down