Skip to content

Commit

Permalink
Merge branch 'swoop' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
svenwoop committed Jan 17, 2017
2 parents 0e10a57 + 88f7ec6 commit f2b8edf
Show file tree
Hide file tree
Showing 22 changed files with 329 additions and 23 deletions.
9 changes: 7 additions & 2 deletions include/embree2/rtcore_geometry.h
Expand Up @@ -69,8 +69,13 @@ enum RTCGeometryFlags
enum RTCBoundaryMode
{
RTC_BOUNDARY_NONE = 0, //!< ignores border patches
RTC_BOUNDARY_EDGE_ONLY = 1, //!< soft boundary (default)
RTC_BOUNDARY_EDGE_AND_CORNER = 2 //!< boundary corner vertices are sharp vertices
RTC_BOUNDARY_SMOOTH = 1, //!< smooth border (default)
RTC_BOUNDARY_PIN_CORNERS= 2, //!< smooth border with fixed corners
RTC_BOUNDARY_PIN_BORDERS = 3, //!< linearly interpolation along border

/* old names for compatibility */
RTC_BOUNDARY_EDGE_ONLY RTCORE_DEPRECATED = 1, //!< soft boundary (default)
RTC_BOUNDARY_EDGE_AND_CORNER RTCORE_DEPRECATED = 2 //!< boundary corner vertices are sharp vertices
};

/*! Intersection filter function for single rays. */
Expand Down
9 changes: 7 additions & 2 deletions include/embree2/rtcore_geometry.isph
Expand Up @@ -69,8 +69,13 @@ enum RTCGeometryFlags
enum RTCBoundaryMode
{
RTC_BOUNDARY_NONE = 0, //!< ignores border patches
RTC_BOUNDARY_EDGE_ONLY = 1, //!< soft boundary (default)
RTC_BOUNDARY_EDGE_AND_CORNER = 2 //!< boundary corner vertices are sharp vertices
RTC_BOUNDARY_SMOOTH = 1, //!< smooth border (default)
RTC_BOUNDARY_PIN_CORNERS= 2, //!< smooth border with fixed corners
RTC_BOUNDARY_PIN_BORDERS = 3, //!< linearly interpolation along border

/* old names for compatibility */
RTC_BOUNDARY_EDGE_ONLY RTCORE_DEPRECATED = 1, //!< soft boundary (default)
RTC_BOUNDARY_EDGE_AND_CORNER RTCORE_DEPRECATED = 2 //!< boundary corner vertices are sharp vertices
};

/*! Intersection filter function for uniform rays. */
Expand Down
36 changes: 26 additions & 10 deletions kernels/common/scene_subdiv_mesh.cpp
Expand Up @@ -31,7 +31,7 @@ namespace embree
numFaces(numFaces),
numEdges(numEdges),
numVertices(numVertices),
boundary(RTC_BOUNDARY_EDGE_ONLY),
boundary(RTC_BOUNDARY_SMOOTH),
displFunc(nullptr),
displFunc2(nullptr),
displBounds(empty),
Expand Down Expand Up @@ -377,24 +377,32 @@ namespace embree
}
});

/* calculate patch types and sharp corners */
/* set boundary mode and calculate patch types */
parallel_for( size_t(0), numFaces, blockSize, [&](const range<size_t>& r)
{
for (size_t f=r.begin(); f<r.end(); f++)
{
HalfEdge* edge = &halfEdges[faceStartEdge[f]];
HalfEdge::PatchType patch_type = edge->patchType();

/* calculate if face is valid */
for (size_t t=0; t<numTimeSteps; t++)
invalidFace(f,t) = !edge->valid(vertices[t]) || holeSet.lookup(unsigned(f));

for (size_t i=0; i<faceVertices[f]; i++)
{
edge[i].patch_type = patch_type;

/* calculate sharp corner vertices */
if (boundary == RTC_BOUNDARY_EDGE_AND_CORNER && edge[i].isCorner())
/* pin corner vertices when requested by user */
if (boundary == RTC_BOUNDARY_PIN_CORNERS && edge[i].isCorner())
edge[i].vertex_crease_weight = float(inf);

/* pin all border vertices when requested by user */
if (boundary == RTC_BOUNDARY_PIN_BORDERS && edge[i].vertexHasBorder())
edge[i].vertex_crease_weight = float(inf);
}

/* we have to calculate patch_type last! */
HalfEdge::PatchType patch_type = edge->patchType();
for (size_t i=0; i<faceVertices[f]; i++)
edge[i].patch_type = patch_type;
}
});
}
Expand Down Expand Up @@ -427,10 +435,18 @@ namespace embree
if (edge.hasOpposite()) // leave weight at inf for borders
edge.edge_crease_weight = edgeCreaseMap.lookup(key,0.0f);
}

if (updateVertexCreases && edge.vertex_type != HalfEdge::NON_MANIFOLD_EDGE_VERTEX) {

/* we only use user specified vertex_crease_weight if the vertex is manifold */
if (updateVertexCreases && edge.vertex_type != HalfEdge::NON_MANIFOLD_EDGE_VERTEX)
{
edge.vertex_crease_weight = vertexCreaseMap.lookup(startVertex,0.0f);
if (boundary == RTC_BOUNDARY_EDGE_AND_CORNER && edge.isCorner())

/* pin corner vertices when requested by user */
if (boundary == RTC_BOUNDARY_PIN_CORNERS && edge.isCorner())
edge.vertex_crease_weight = float(inf);

/* pin all border vertices when requested by user */
if (boundary == RTC_BOUNDARY_PIN_BORDERS && edge.vertexHasBorder())
edge.vertex_crease_weight = float(inf);
}

Expand Down
6 changes: 3 additions & 3 deletions kernels/subdiv/half_edge.h
Expand Up @@ -150,7 +150,7 @@ namespace embree
__forceinline bool isCorner() const {
return !hasOpposite() && !prev()->hasOpposite();
}

/*! tests if the vertex is attached to any border */
__forceinline bool vertexHasBorder() const
{
Expand Down Expand Up @@ -209,8 +209,8 @@ namespace embree
"prev = " << h.prev_half_edge_ofs << ", " <<
"next = " << h.next_half_edge_ofs << ", " <<
"opposite = " << h.opposite_half_edge_ofs << ", " <<
//"edge_crease = " << h.edge_crease_weight << ", " <<
//"vertex_crease = " << h.vertex_crease_weight << ", " <<
"edge_crease = " << h.edge_crease_weight << ", " <<
"vertex_crease = " << h.vertex_crease_weight << ", " <<
//"edge_level = " << h.edge_level <<
" }";
}
Expand Down
1 change: 1 addition & 0 deletions tutorials/buildbench/buildbench_device.cpp
Expand Up @@ -70,6 +70,7 @@ namespace embree {
rtcSetBuffer(scene_out, geomID, RTC_EDGE_CREASE_WEIGHT_BUFFER, mesh->edge_crease_weights, 0, sizeof(float));
rtcSetBuffer(scene_out, geomID, RTC_VERTEX_CREASE_INDEX_BUFFER, mesh->vertex_creases, 0, sizeof(unsigned int));
rtcSetBuffer(scene_out, geomID, RTC_VERTEX_CREASE_WEIGHT_BUFFER, mesh->vertex_crease_weights, 0, sizeof(float));
rtcSetBoundaryMode(scene_out, geomID, mesh->boundaryMode);
return geomID;
}

Expand Down
2 changes: 1 addition & 1 deletion tutorials/common/scenegraph/scenegraph.cpp
Expand Up @@ -741,7 +741,7 @@ namespace embree
mesh->verticesPerFace[i] = 4;
}
}
mesh->boundaryMode = RTC_BOUNDARY_EDGE_AND_CORNER;
mesh->boundaryMode = RTC_BOUNDARY_PIN_CORNERS;
return mesh;
}

Expand Down
2 changes: 1 addition & 1 deletion tutorials/common/scenegraph/scenegraph.h
Expand Up @@ -518,7 +518,7 @@ namespace embree
typedef Vec3fa Vertex;

SubdivMeshNode (Ref<MaterialNode> material, size_t numTimeSteps = 0)
: Node(true), material(material), boundaryMode(RTC_BOUNDARY_EDGE_ONLY), tessellationRate(2.0f)
: Node(true), material(material), boundaryMode(RTC_BOUNDARY_SMOOTH), tessellationRate(2.0f)
{
for (size_t i=0; i<numTimeSteps; i++)
positions.push_back(avector<Vertex>());
Expand Down
6 changes: 6 additions & 0 deletions tutorials/common/scenegraph/xml_loader.cpp
Expand Up @@ -909,6 +909,12 @@ namespace embree
mesh->positions.push_back(loadVec3faArray(xml->childOpt("positions2")));
}

std::string boundary = xml->parm("boundary");
if (boundary == "smooth" ) mesh->boundaryMode = RTC_BOUNDARY_SMOOTH;
else if (boundary == "pin_corners") mesh->boundaryMode = RTC_BOUNDARY_PIN_CORNERS;
else if (boundary == "pin_borders") mesh->boundaryMode = RTC_BOUNDARY_PIN_BORDERS;
else if (boundary != "" ) THROW_RUNTIME_ERROR("invalid boundary mode: "+boundary);

mesh->normals = loadVec3faArray(xml->childOpt("normals"));
mesh->texcoords = loadVec2fArray(xml->childOpt("texcoords"));
mesh->position_indices = loadUIntArray(xml->childOpt("position_indices"));
Expand Down
3 changes: 2 additions & 1 deletion tutorials/common/tutorial/scene.h
Expand Up @@ -171,7 +171,7 @@ namespace embree
struct SubdivMesh : public Geometry
{
SubdivMesh (Ref<SceneGraph::SubdivMeshNode> mesh, const SceneGraph::Transformations& spaces, unsigned materialID)
: Geometry(SUBDIV_MESH), numTimeSteps((unsigned int)mesh->numTimeSteps()), numPositions((unsigned int)mesh->numPositions()), materialID(materialID)
: Geometry(SUBDIV_MESH), boundaryMode(mesh->boundaryMode), numTimeSteps((unsigned int)mesh->numTimeSteps()), numPositions((unsigned int)mesh->numPositions()), materialID(materialID)
{
positions.resize(numTimeSteps*numPositions);
for (size_t t=0; t<numTimeSteps; t++) {
Expand Down Expand Up @@ -211,6 +211,7 @@ namespace embree
std::vector<float> edge_crease_weights; //!< weight for each edge crease
std::vector<unsigned> vertex_creases; //!< indices of vertex creases
std::vector<float> vertex_crease_weights; //!< weight for each vertex crease
RTCBoundaryMode boundaryMode;

unsigned numTimeSteps;
unsigned numPositions;
Expand Down
4 changes: 3 additions & 1 deletion tutorials/common/tutorial/scene_device.h
Expand Up @@ -133,7 +133,8 @@ namespace embree

struct ISPCSubdivMesh
{
ISPCSubdivMesh (Ref<TutorialScene::SubdivMesh> in) : geom(SUBDIV_MESH)
ISPCSubdivMesh (Ref<TutorialScene::SubdivMesh> in)
: geom(SUBDIV_MESH), boundaryMode(in->boundaryMode)
{
positions = in->positions.data();
normals = in->normals.data();
Expand Down Expand Up @@ -206,6 +207,7 @@ namespace embree
unsigned int numHoles;
unsigned int materialID;
unsigned int geomID;
RTCBoundaryMode boundaryMode;
};

struct ISPCLineSegments
Expand Down
1 change: 1 addition & 0 deletions tutorials/common/tutorial/scene_device.isph
Expand Up @@ -95,6 +95,7 @@ struct ISPCSubdivMesh
unsigned int numHoles;
unsigned int materialID;
unsigned int geomID;
RTCBoundaryMode boundaryMode;
};

struct ISPCHair
Expand Down
88 changes: 88 additions & 0 deletions tutorials/models/subdiv_boundary_pin_borders.xml
@@ -0,0 +1,88 @@
<?xml version="1.0"?>

<scene>
<Group>
<SubdivisionMesh boundary="pin_borders">

<positions>
-2.0 +2.5 0.0 <!-- 0 -->
-1.0 +2.5 0.0 <!-- 1 -->
-0.5 +2.5 0.0 <!-- 2 -->
+0.5 +2.5 0.0 <!-- 3 -->
+1.0 +2.5 0.0 <!-- 4 -->
+2.0 +2.5 0.0 <!-- 5 -->

-2.0 +1.5 0.0 <!-- 6 -->
-1.0 +1.5 0.0 <!-- 7 -->
+0.0 +1.5 0.0 <!-- 8 -->
+1.0 +1.5 0.0 <!-- 9 -->
+2.0 +1.5 0.0 <!-- 10 -->

-2.0 0.5 0.0 <!-- 11 -->
-1.0 0.5 0.0 <!-- 12 -->
+0.0 -0.5 0.0 <!-- 13 -->
+1.0 0.5 0.0 <!-- 14 -->
+2.0 0.5 0.0 <!-- 15 -->

-2.0 -0.5 0.0 <!-- 16 -->
-1.25 -0.5 0.0 <!-- 17 -->
-0.5 -1.5 0.0 <!-- 18 -->
+0.5 -1.5 0.0 <!-- 19 -->
+1.25 -0.5 0.0 <!-- 20 -->
+2.0 -0.5 0.0 <!-- 21 -->

-2.0 -1.5 0.0 <!-- 22 -->
-1.25 -1.5 0.0 <!-- 23 -->
-0.5 -2.0 0.0 <!-- 24 -->
+0.5 -2.0 0.0 <!-- 25 -->
+1.25 -1.5 0.0 <!-- 26 -->
+2.0 -1.5 0.0 <!-- 27 -->

-2.0 -2.5 0.0 <!-- 28 -->
-1.25 -2.5 0.0 <!-- 29 -->
-0.5 -2.5 0.0 <!-- 30 -->
+0.5 -2.5 0.0 <!-- 31 -->
+1.25 -2.5 0.0 <!-- 32 -->
+2.0 -2.5 0.0 <!-- 33 -->
</positions>

<position_indices>
0 1 7 6
1 2 8 7
3 4 9 8
4 5 10 9

6 7 12 11
7 8 13 12
8 9 14 13
9 10 15 14

16 17 23 22
17 18 24 23
19 20 26 25
20 21 27 26

22 23 29 28
23 24 30 29
25 26 32 31
26 27 33 32

</position_indices>

<faces>
4 4 4 4
4 4 4 4
4 4 4 4
4 4 4 4
</faces>

<material>
<code>"OBJ"</code>
<parameters>
<float3 name="Kd">1 1 1</float3>
</parameters>
</material>

</SubdivisionMesh>
</Group>
</scene>
87 changes: 87 additions & 0 deletions tutorials/models/subdiv_boundary_pin_corners.xml
@@ -0,0 +1,87 @@
<?xml version="1.0"?>

<scene>
<Group>
<SubdivisionMesh boundary="pin_corners">

<positions>
-2.0 +2.5 0.0 <!-- 0 -->
-1.0 +2.5 0.0 <!-- 1 -->
-0.5 +2.5 0.0 <!-- 2 -->
+0.5 +2.5 0.0 <!-- 3 -->
+1.0 +2.5 0.0 <!-- 4 -->
+2.0 +2.5 0.0 <!-- 5 -->

-2.0 +1.5 0.0 <!-- 6 -->
-1.0 +1.5 0.0 <!-- 7 -->
+0.0 +1.5 0.0 <!-- 8 -->
+1.0 +1.5 0.0 <!-- 9 -->
+2.0 +1.5 0.0 <!-- 10 -->

-2.0 0.5 0.0 <!-- 11 -->
-1.0 0.5 0.0 <!-- 12 -->
+0.0 -0.5 0.0 <!-- 13 -->
+1.0 0.5 0.0 <!-- 14 -->
+2.0 0.5 0.0 <!-- 15 -->

-2.0 -0.5 0.0 <!-- 16 -->
-1.25 -0.5 0.0 <!-- 17 -->
-0.5 -1.5 0.0 <!-- 18 -->
+0.5 -1.5 0.0 <!-- 19 -->
+1.25 -0.5 0.0 <!-- 20 -->
+2.0 -0.5 0.0 <!-- 21 -->

-2.0 -1.5 0.0 <!-- 22 -->
-1.25 -1.5 0.0 <!-- 23 -->
-0.5 -2.0 0.0 <!-- 24 -->
+0.5 -2.0 0.0 <!-- 25 -->
+1.25 -1.5 0.0 <!-- 26 -->
+2.0 -1.5 0.0 <!-- 27 -->

-2.0 -2.5 0.0 <!-- 28 -->
-1.25 -2.5 0.0 <!-- 29 -->
-0.5 -2.5 0.0 <!-- 30 -->
+0.5 -2.5 0.0 <!-- 31 -->
+1.25 -2.5 0.0 <!-- 32 -->
+2.0 -2.5 0.0 <!-- 33 -->
</positions>

<position_indices>
0 1 7 6
1 2 8 7
3 4 9 8
4 5 10 9

6 7 12 11
7 8 13 12
8 9 14 13
9 10 15 14

16 17 23 22
17 18 24 23
19 20 26 25
20 21 27 26

22 23 29 28
23 24 30 29
25 26 32 31
26 27 33 32
</position_indices>

<faces>
4 4 4 4
4 4 4 4
4 4 4 4
4 4 4 4
</faces>

<material>
<code>"OBJ"</code>
<parameters>
<float3 name="Kd">1 1 1</float3>
</parameters>
</material>

</SubdivisionMesh>
</Group>
</scene>

0 comments on commit f2b8edf

Please sign in to comment.