Page MenuHome

Task T47222: Option to use 3D cursor-center instead of origin for UV unwrapping (cube, cylinder, sphere)
AbandonedPublic

Authored by Rohan Rathi (RohanRathi) on Feb 5 2017, 7:00 PM.

Details

Summary

Diff to solve Task T47222 in Quick Hacks based on previous work with added modifications.

Created an option for UV unwrapping from cursor position.

Diff Detail

Event Timeline

Rohan Rathi (RohanRathi) retitled this revision from to Task T47222: Option to use 3D cursor-center instead of origin for UV unwrapping (cube, cylinder, sphere).
Rohan Rathi (RohanRathi) updated this object.
Rohan Rathi (RohanRathi) set the repository for this revision to rB Blender.
Germano Cavalcante (mano-wii) requested changes to this revision.Mar 30 2017, 5:31 AM

Hi @Rohan Rathi (RohanRathi),

The code works... in part. (There are some problems):

source/blender/editors/uvedit/uvedit_unwrap_ops.c
1500
*center = *ED_view3d_cursor3d_get(scene, v3d);``` is wrong :\

`center` here is only copying the first element of the array (center[0]).
Try using `copy_v3_v3(center, ED_view3d_cursor3d_get(scene, v3d))` instead.

There is also no need to calculate the previous value of the `center` since it is overwritten by the cursor3d. This is inefficient. You must separate the function that calculates the `center` and only use with `else`.
1586

same as the previous comment

1680

This function is very similar to ED_uvedit_unwrap_cube_project. Try to avoid duplicates. This increases the code and makes it difficult to maintain.

It is also difficult to say what is this float *off
Try to be more descriptive like const float offset[3].

Suggestion: You can add this parameter to ED_uvedit_unwrap_cube_project And put as NULL if it does not have offset.

ED_uvedit_unwrap_cube_project(ob, bm, cube_size, NULL);
This revision now requires changes to proceed.Mar 30 2017, 5:31 AM
Rohan Rathi (RohanRathi) edited edge metadata.

Thanks for the feedback, fixed.

Germano Cavalcante (mano-wii) requested changes to this revision.Apr 22 2017, 1:28 AM
Germano Cavalcante (mano-wii) added inline comments.
source/blender/editors/include/ED_uvedit.h
104

use const float offset[3]... becomes more descriptive

source/blender/editors/uvedit/uvedit_unwrap_ops.c
976

In this case this function can be independent. The center can be obtained outside

1491

Why not call cursor_center just like the name of the property?

1502

Be careful about the value of center being local

1639

const float offset[3]

1678

The loc value can be changed before the loop.
Ex.:

	float loc[3];

	if (offset) {
		add_v3_v3v3(loc, ob->obmat[3], offset);
	}
	else {
		copy_v3_v3(loc, ob->obmat[3]);
	}
1705

~cursor_unwrap~ > cursor_center

1708

The value of cursor_loc must be local

This revision now requires changes to proceed.Apr 22 2017, 1:28 AM
Rohan Rathi (RohanRathi) marked 9 inline comments as done.Apr 26 2017, 7:55 PM

Hi, I didn't catch a few remarks.
About the value of 'center' being local, it shouldn't be local to the IF statement as it has been declared earlier?
Also, I believe the value of cursor_loc may actually be local as suggested.

Am I missing something?

Hi, I didn't catch a few remarks.
About the value of 'center' being local, it shouldn't be local to the IF statement as it has been declared earlier?

I mean being local in Blender 3DView. Taking into account the matrix of the object

Went to apply this patch but found the use of center values was buggy and not always in the correct space.

Committed related changes rB759b50b20b96556f182e6d14ce23a89e2a673921

Currently there are a handful of tools that use v3d->around - We could make this into an operator option, so the user can optionally override the 3d view.