I add the code to luxcore, I will request dade to give me access to the luxcore repo so I can push the code on server
If you can complete the luxcore from the source you can do it like this.
add these lines in loxcore.h after DeleteObject definition around line 1079. it should look like something like that.
Code: Select all
virtual void DeleteObject(const std::string &objName) = 0;
virtual void DeleteObjects(std::vector<std::string> &names) = 0;
virtual void DeleteObjectsInstance(const std::string &prefixName, const unsigned int count, const unsigned int start) = 0;
add these lines in scene.h after DeleteObject definition around line 157. it should look like something like that.
Code: Select all
void DeleteObject(const std::string &objName);
void DeleteObjects(std::vector<std::string> &names);
void DeleteObjectsInstance(const std::string &prefixName, const unsigned int count, const unsigned int start);
and finally, add these lines in scene.cpp after DeleteObject definition around line 481. it should look like something like that.
Code: Select all
void Scene::DeleteObject(const string &objName) {
if (objDefs.IsSceneObjectDefined(objName)) {
const SceneObject *oldObj = objDefs.GetSceneObject(objName);
const bool wasLightSource = oldObj->GetMaterial()->IsLightSource();
// Check if the old object was a light source
if (wasLightSource) {
editActions.AddActions(LIGHTS_EDIT | LIGHT_TYPES_EDIT);
// Delete all old triangle lights
const ExtMesh *mesh = oldObj->GetExtMesh();
for (u_int i = 0; i < mesh->GetTotalTriangleCount(); ++i)
lightDefs.DeleteLightSource(oldObj->GetName() + TRIANGLE_LIGHT_POSTFIX + ToString(i));
}
objDefs.DeleteSceneObject(objName);
editActions.AddAction(GEOMETRY_EDIT);
}
}
void Scene::DeleteObjects(std::vector<std::string> &names) {
BOOST_FOREACH(const string &objName, names) {
DeleteObject(objName);
}
}
void Scene::DeleteObjectsInstance(const std::string &prefixName, const unsigned int count, const unsigned int start) {
for (unsigned int i = start; i < start + count; i++)
{
string objectName = prefixName + std::to_string(i);
DeleteObject(objectName);
}
}
now you can compile the code and use it like this.
Scene->DeleteObject(objName); // delete one single object as always. objName = object name in String
Scene->DeleteObjects(objNames); // delete a list of object. objectNames = vector of object names in String
Scene->DeleteObjectsInstance(objPrefixName, count); // delete multiple instance objects. objPrefixName = instance prefix name in String, count = number of instance to be deleted, start = is the number of instance to start to delete from it
To make it safer you can check if the start + count is not bigger than existing instance numbers. as the existence of the object will be always checked in the DeleteObject function it should not be a problem.
it is possible to make all functions as it is in duplicating instances in the same name but I prefer different names to avoid confusion.
If you are using Pyluxcore you need to add the functions there too.
you can manipulate the code to fit your needs.