diff options
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_geom.h | 23 | ||||
-rw-r--r-- | source/blender/blenlib/intern/bpath.c | 10 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 23 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 6 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 2 |
5 files changed, 53 insertions, 11 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index ffc4bfe79e6..74869ca347b 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -62,7 +62,7 @@ float dist_to_line_v2(const float p[2], const float l1[2], const float l2[2]); float dist_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2]); void closest_to_line_segment_v2(float closest[2], const float p[2], const float l1[2], const float l2[2]); -float dist_to_plane_v3(const float p[2], const float plane_co[3], const float plane_no[2]); +float dist_to_plane_v3(const float p[3], const float plane_co[3], const float plane_no[3]); float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]); float closest_to_line_v3(float r[3], const float p[3], const float l1[3], const float l2[3]); float closest_to_line_v2(float r[2], const float p[2], const float l1[2], const float l2[2]); @@ -94,9 +94,11 @@ int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[ * */ int isect_line_line_v3(const float v1[3], const float v2[3], - const float v3[3], const float v4[3], float i1[3], float i2[3]); + const float v3[3], const float v4[3], + float i1[3], float i2[3]); int isect_line_line_strict_v3(const float v1[3], const float v2[3], - const float v3[3], const float v4[3], float vi[3], float *lambda); + const float v3[3], const float v4[3], + float vi[3], float *lambda); /*if clip is nonzero, will only return true if lambda is >= 0.0 (i.e. intersection point is along positive d)*/ @@ -115,6 +117,21 @@ int isect_ray_plane_v3(float p1[3], float d[3], float v0[3], int isect_line_plane_v3(float out[3], const float l1[3], const float l2[3], const float plane_co[3], const float plane_no[3], const short no_flip); +/** + * Intersect two planes, return a point on the intersection and a vector + * that runs on the direction of the intersection. + * Return error code is the same as 'isect_line_line_v3'. + * @param r_isect_co The resulting intersection point. + * @param r_isect_no The resulting vector of the intersection. + * @param plane_a_co The point on the first plane. + * @param plane_a_no The normal of the first plane. + * @param plane_b_co The point on the second plane. + * @param plane_b_no The normal of the second plane. + */ +int isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3], + const float plane_a_co[3], const float plane_a_no[3], + const float plane_b_co[3], const float plane_b_no[3]); + /* line/ray triangle */ int isect_line_tri_v3(const float p1[3], const float p2[3], const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2]); diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index 8ad79dd819a..8ad6cfc7cdf 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -131,7 +131,7 @@ static int makeFilesRelative_visit_cb(void *userdata, char *path_dst, const char void makeFilesRelative(Main *bmain, const char *basedir, ReportList *reports) { - BPathRemap_Data data= {0}; + BPathRemap_Data data= {NULL}; if(basedir[0] == '\0') { printf("%s: basedir='', this is a bug\n", __func__); @@ -174,7 +174,7 @@ static int makeFilesAbsolute_visit_cb(void *userdata, char *path_dst, const char /* similar to makeFilesRelative - keep in sync! */ void makeFilesAbsolute(Main *bmain, const char *basedir, ReportList *reports) { - BPathRemap_Data data= {0}; + BPathRemap_Data data= {NULL}; if(basedir[0] == '\0') { printf("%s: basedir='', this is a bug\n", __func__); @@ -280,7 +280,7 @@ static int findMissingFiles_visit_cb(void *userdata, char *path_dst, const char void findMissingFiles(Main *bmain, const char *searchpath, ReportList *reports) { - struct BPathFind_Data data= {0}; + struct BPathFind_Data data= {NULL}; data.reports= reports; BLI_split_dir_part(searchpath, data.searchdir, sizeof(data.searchdir)); @@ -431,6 +431,10 @@ void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int fla ClothModifierData *clmd= (ClothModifierData*) md; BPATH_TRAVERSE_POINTCACHE(clmd->ptcaches); } + else if (md->type==eModifierType_Ocean) { + OceanModifierData *omd= (OceanModifierData*) md; + rewrite_path_fixed(omd->cachepath, visit_cb, absbase, bpath_user_data); + } } if (ob->soft) { diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 23a37dadebe..fa041158c90 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -238,7 +238,7 @@ void closest_to_line_segment_v3(float closest[3], const float v1[3], const float } /* signed distance from the point to the plane in 3D */ -float dist_to_plane_v3(const float p[2], const float plane_co[3], const float plane_no[2]) +float dist_to_plane_v3(const float p[3], const float plane_co[3], const float plane_no[3]) { float plane_no_unit[3]; float plane_co_other[3]; @@ -833,6 +833,27 @@ int isect_line_plane_v3(float out[3], const float l1[3], const float l2[3], cons } } +int isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3], + const float plane_a_co[3], const float plane_a_no[3], + const float plane_b_co[3], const float plane_b_no[3]) +{ + float p1_co_other[3], p2_co_other[3]; + float isect_co_dummy[3]; + + cross_v3_v3v3(r_isect_no, plane_a_no, plane_b_no); + cross_v3_v3v3(p1_co_other, plane_a_no, r_isect_no); + cross_v3_v3v3(p2_co_other, plane_b_no, r_isect_no); + + add_v3_v3(p1_co_other, plane_a_co); + add_v3_v3(p2_co_other, plane_b_co); + + /* we could use either ix_1, ix_2 - doesnt matter in this case */ + return isect_line_line_v3(plane_a_co, p1_co_other, + plane_b_co, p2_co_other, + r_isect_co, isect_co_dummy); +} + + /* Adapted from the paper by Kasper Fauerby */ /* "Improved Collision detection and Response" */ static int getLowestRoot(const float a, const float b, const float c, const float maxR, float *root) diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index f6ba4ec43ad..f6dd28c3151 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -181,19 +181,19 @@ MINLINE void add_v4_fl(float r[4], float f) r[3] += f; } -MINLINE void add_v2_v2(float *r, const float *a) +MINLINE void add_v2_v2(float r[2], const float a[2]) { r[0] += a[0]; r[1] += a[1]; } -MINLINE void add_v2_v2v2(float *r, const float *a, const float *b) +MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2]) { r[0]= a[0] + b[0]; r[1]= a[1] + b[1]; } -MINLINE void add_v3_v3(float *r, const float *a) +MINLINE void add_v3_v3(float r[3], const float a[3]) { r[0] += a[0]; r[1] += a[1]; diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index e7031c943c1..2bf7c7c4039 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1842,7 +1842,7 @@ const char *BLI_program_dir(void) * @param fullname The full path to the temp directory * @param userdir Directory specified in user preferences */ -void BLI_where_is_temp(char *fullname, const size_t maxlen, char *userdir) +static void BLI_where_is_temp(char *fullname, const size_t maxlen, char *userdir) { fullname[0] = '\0'; |