-
Notifications
You must be signed in to change notification settings - Fork 49
Rtc occluded #9
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
Rtc occluded #9
Changes from 2 commits
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 |
|---|---|---|
|
|
@@ -9,3 +9,5 @@ pyembree/*.pyc | |
| pyembree.egg-info/ | ||
| dist/ | ||
| *.png | ||
|
|
||
| .idea | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,10 @@ cimport rtcore as rtc | |
| cimport rtcore_ray as rtcr | ||
| cimport rtcore_geometry as rtcg | ||
|
|
||
| cdef enum rayQueryType: | ||
| intersect, | ||
| occluded | ||
|
Owner
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. I don't think that this is the correct syntax for enums |
||
|
|
||
| cdef void error_printer(const rtc.RTCError code, const char *_str): | ||
| print "ERROR CAUGHT IN EMBREE" | ||
| rtc.print_error(code) | ||
|
|
@@ -19,12 +23,21 @@ cdef class EmbreeScene: | |
|
|
||
| def run(self, np.ndarray[np.float64_t, ndim=2] vec_origins, | ||
| np.ndarray[np.float64_t, ndim=2] vec_directions, | ||
| dists=None): | ||
| dists=None,query='INTERSECT'): | ||
| rtcCommit(self.scene_i) | ||
| cdef int nv = vec_origins.shape[0] | ||
| cdef int vo_i, vd_i, vd_step | ||
| cdef np.ndarray[np.int32_t, ndim=1] intersect_ids | ||
| cdef np.ndarray[np.float32_t, ndim=1] tfars | ||
| cdef rayQueryType query_type | ||
|
|
||
| if query == 'INTERSECT': | ||
| query_type = intersect | ||
| elif query == 'OCCLUDED': | ||
| query_type = occluded | ||
|
Owner
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. Why be based on strings rather than a Python enums? Does pyembree still support Python 2.7?
Contributor
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. For what it's worth, yt uses pyembree and still supports Python2.7, so it would be in our interests to keep it there for a little while longer. There are other bits in pyembree that use strings, IIRC.
Owner
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. That is fair. I was just wondering. It isn't 2020 yet :)
Contributor
Author
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. Yea, I'm still using it in a python 2.7 project as well. |
||
| else: | ||
| raise ValueError("Embree ray query type %s not recognized" % (query)) | ||
|
|
||
| if dists is None: | ||
| tfars = np.empty(nv, 'float32') | ||
| tfars.fill(1e37) | ||
|
|
@@ -36,6 +49,7 @@ cdef class EmbreeScene: | |
| vd_step = 1 | ||
| # If vec_directions is 1 long, we won't be updating it. | ||
| if vec_directions.shape[0] == 1: vd_step = 0 | ||
|
|
||
| for i in range(nv): | ||
| for j in range(3): | ||
| ray.org[j] = vec_origins[i, j] | ||
|
|
@@ -49,8 +63,13 @@ cdef class EmbreeScene: | |
| ray.mask = -1 | ||
| ray.time = 0 | ||
| vd_i += vd_step | ||
| rtcIntersect(self.scene_i, ray) | ||
| intersect_ids[i] = ray.primID | ||
|
|
||
| if query_type==intersect: | ||
|
Owner
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. PEP8 spaces around operators |
||
| rtcIntersect(self.scene_i, ray) | ||
| intersect_ids[i] = ray.primID | ||
| else: | ||
| rtcOccluded(self.scene_i, ray) | ||
| intersect_ids[i] = ray.geomID | ||
|
|
||
| return intersect_ids | ||
|
|
||
|
|
||
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.
not PEP8 compliant. Should this be in a pxd file instead?