-
Notifications
You must be signed in to change notification settings - Fork 98
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 mesh simplification attribute to <mesh> #1380
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
<element name="mesh" required="0"> | ||
<description>Mesh shape</description> | ||
|
||
<attribute name="simplification" type="string" default="" required="0"> | ||
<description> | ||
Set whether to simplify the mesh using one of the specified methods. Values include: "convex_hull", "convex_decomposition". Default value is an empty string which means no mesh simplification. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could it make sense to add a sentence, a link or a reference to what these methods mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. expanded this to include description for the values. 64d7c97 |
||
</description> | ||
</attribute> | ||
|
||
<element name="uri" type="string" default="__default__" required="1"> | ||
<description>Mesh uri</description> | ||
</element> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,9 @@ using namespace sdf; | |
// Private data class | ||
class sdf::Mesh::Implementation | ||
{ | ||
/// \brief Mesh simplification method | ||
public: std::string simplification; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe use a enum here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added enum in 64d7c97 |
||
|
||
/// \brief The mesh's URI. | ||
public: std::string uri = ""; | ||
|
||
|
@@ -87,6 +90,13 @@ Errors Mesh::Load(ElementPtr _sdf, const ParserConfig &_config) | |
return errors; | ||
} | ||
|
||
// Simplify | ||
if (_sdf->HasAttribute("simplification")) | ||
{ | ||
this->dataPtr->simplification = _sdf->Get<std::string>("simplification", | ||
this->dataPtr->simplification).first; | ||
} | ||
|
||
if (_sdf->HasElement("uri")) | ||
{ | ||
std::unordered_set<std::string> paths; | ||
|
@@ -140,6 +150,18 @@ sdf::ElementPtr Mesh::Element() const | |
return this->dataPtr->sdf; | ||
} | ||
|
||
////////////////////////////////////////////////// | ||
std::string Mesh::Simplification() const | ||
{ | ||
return this->dataPtr->simplification; | ||
} | ||
|
||
////////////////////////////////////////////////// | ||
void Mesh::SetSimplification(const std::string &_simplification) | ||
{ | ||
this->dataPtr->simplification = _simplification; | ||
} | ||
|
||
////////////////////////////////////////////////// | ||
std::string Mesh::Uri() const | ||
{ | ||
|
@@ -244,6 +266,10 @@ sdf::ElementPtr Mesh::ToElement(sdf::Errors &_errors) const | |
sdf::ElementPtr elem(new sdf::Element); | ||
sdf::initFile("mesh_shape.sdf", elem); | ||
|
||
// Simplification | ||
elem->GetAttribute("simplification")->Set<std::string>( | ||
this->dataPtr->simplification); | ||
|
||
// Uri | ||
sdf::ElementPtr uriElem = elem->GetElement("uri", _errors); | ||
uriElem->Set(_errors, this->Uri()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to decide if
simplification
is the right name for this attribute.Alternatives (which might not be better):
//mesh/@transformation
//mesh/@convexity
with candidate values:
use_convex_hull
use_convex_decomposition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
transformation
is generic and would be another good candidate. So we don't limit this to just creating convex meshes