Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/util/ed_transverts.c
| Context not available. | |||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_rand.h" | |||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_depsgraph.h" | #include "BKE_depsgraph.h" | ||||
| #include "BKE_lattice.h" | #include "BKE_lattice.h" | ||||
| #include "BKE_editmesh.h" | #include "BKE_editmesh.h" | ||||
| #include "BKE_DerivedMesh.h" | #include "BKE_DerivedMesh.h" | ||||
| #include "BKE_context.h" | |||||
| #include "ED_armature.h" | #include "ED_armature.h" | ||||
| Context not available. | |||||
| MEM_SAFE_FREE(tvs->transverts); | MEM_SAFE_FREE(tvs->transverts); | ||||
| tvs->transverts_tot = 0; | tvs->transverts_tot = 0; | ||||
| } | } | ||||
| void ED_transverts_randomize(Object *ob, bool x, bool y, bool z, float amp, int freq) | |||||
| { | |||||
| TransVertStore tvs; | |||||
| TransVert *tv; | |||||
| float rand_mat[3] = {0.0f, 0.0f, 0.0f}; | |||||
| int i; | |||||
| ED_transverts_create_from_obedit(&tvs, ob, TM_ALL_JOINTS); | |||||
| tv = tvs.transverts; | |||||
| for(i = 0; i < tvs.transverts_tot; i += freq, tv += freq) { | |||||
aligorith: Whitespace nitpick - There should be a single space between "for" and the opening paren (i.e. | |||||
Not Done Inline Actionsfine for test but we have some better noise functions. campbellbarton: fine for test but we have some better noise functions. | |||||
| if(x == true) { | |||||
Not Done Inline ActionsIMO it's probably better that you don't try to squeeze everything onto a single line here using a ternary operator and assignment statements nested inside this. AFAIK, there's no real performance gain from doing this, while the non-standard syntax can momentarily trip people up (mainly by overlooking where exactly the assignments are happening). aligorith: IMO it's probably better that you don't try to squeeze everything onto a single line here using… | |||||
| (rand_mat[0] = ((BLI_rand() % 2 - 1) * amp)); | |||||
| } | |||||
| else | |||||
| (rand_mat[0] = 0.0f); | |||||
| if(y == true) { | |||||
| (rand_mat[1] = ((BLI_rand() % 2 - 1) * amp)); | |||||
| } | |||||
| else | |||||
| (rand_mat[1] = 0.0f); | |||||
| if(z == true) { | |||||
| (rand_mat[2] = ((BLI_rand() % 2 - 1) * amp)); | |||||
| } | |||||
| else | |||||
| (rand_mat[2] = 0.0f); | |||||
| add_v3_v3(tv->loc, rand_mat); | |||||
| } | |||||
| ED_transverts_update_obedit(&tvs, ob); | |||||
| ED_transverts_free(&tvs); | |||||
| } | |||||
| int ED_transverts_obedit_poll(struct bContext *C) | |||||
| { | |||||
| Object *obedit = CTX_data_edit_object(C); | |||||
| if (obedit) { | |||||
| if (ED_transverts_check_obedit(obedit)) { | |||||
| return true; | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | |||||
| Context not available. | |||||
Whitespace nitpick - There should be a single space between "for" and the opening paren (i.e. "for (..." instead of "for(...") and the same goes for the end of the line here (i.e. "freq) {" instead of "freq){")