Extrude Op selection issue

Extrude Op selection issue

Postby Skinnytorus » Sunday, 13.May 2012, 10:22

hi, all!
Have you ever tried to make insets in wz4? I did and faced a problem.
If you, say, wanna make 'windows' in a cube, you subdivide it, select the faces you want to have insets for 'windows' using Select op and then extrude the 'windows' inwards using Extrude op with zero Amount and negative Scale.

What happens next is quite unexpected: the Extrude op changes your selection of faces and leaves only the newly created fases selected, but not the faces you have just extruded. So, in order to select the 'windows' for another extrusion you'll have to use logic by stacking a couple of other Select ops beneath the extrude op. So, my idea is to tweak this behaviour so that you can have original faces selected after extrusion. Two ways possible imho:

1. Modify the existing Extrude op by placing a switch using a boole function which defaults to the current select behaviour (for compartibility). It's _kb's idea, actually ;)) or
2. Create a duplicate of Extrude op behaving like we wnt, call it Extrude 2 or Inset and populate it over the whole structure.

The hardest part (as always) is implementation :)).
It seems that this part of wz4_mesh.cpp is responsible for selection.

// update selection
sFORALL (Vertices,v)
v->Select = 0.0f;
sFORALL (Faces,f)
f->Select = (_i>=originalfacecount)?1.0f:0.0f;

This part calls sFORALL function defined in types.hpp. Apparently, sFORALL forms (or sorts)the respective vert/face array. Then I get lost. I can not figure out how these arrays are sorted and thus can not imagine the order...

Well, then the selecion goes. If new faces are created (_i>=originalfacecount), they get selected (i.e 1.0f), if they are not, the selection must stay the same as original(i.e. 0.0f).

If I change 1.0f to 0.0f, the Extrude op leaves nothing selected at all, which makes me think there must be some sorting problem originating from sFORALL function or maybe v and f do not contain the original faces. What could that be?

Anyway, I'm totally confused and ask for your help. Maybe some C++ guru might take a look at that?
Thank you.

PS I'm total noob to C++ programing, so excuse me if I'd made foolish statements :))
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Extrude Op selection issue

Postby ikam » Sunday, 13.May 2012, 21:14

Hi Skinnytorus

Good analysis !

I've take a look, in fact, when updating selection after extrusion, it only set newest faces into selection (and delete others)...

sFORALL (Faces,f)
f->Select = (_i>=originalfacecount)?1.0f:0.0f;

=> sFORALL is a macro to simply write a foreach style loop (like in php) - 'Faces' is the array to loop in and 'f' is a pointer to current element in array.
so for all faces in "Faces" array (which contains all faces of the mesh + new extruded faces) it add into selection only newest faces ( _i > originalfacecount )...

it's a quiet bizarre... In my opinion after extruding, origin selection musn't be changed...
this can be done by storing original selected faces at begining and restore them at end of extrusion, I wrote this and it works fine.

here a compiled version for testing : werkkzeug4_extrude_test.rar
ikam
Operator
Operator
 
Posts: 911
Joined: Friday, 14.October 2011, 13:00
Location: France

Re: Extrude Op selection issue

Postby Skinnytorus » Sunday, 13.May 2012, 21:48

Holy sh..t! You did it! Congrats, fellow! At last a familiar extrude mode! :) Thanks.
What have you changed? Very interesting to know that!
Well, now that it's done, maybe it's time to think of compartibility with older wz4 files.
How about the first way I mentioned above? This seems less 'painful', doesn't it?
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Extrude Op selection issue

Postby ikam » Sunday, 13.May 2012, 21:59

yes, first way is quite easy to do, i've already done this with bend ops (to add a selection flag). I'll add this tomorrow and post it to github :)
ikam
Operator
Operator
 
Posts: 911
Joined: Friday, 14.October 2011, 13:00
Location: France

Re: Extrude Op selection issue

Postby Skinnytorus » Sunday, 13.May 2012, 22:03

so good to hear that, man. all thumbs up and respect. :)
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Extrude Op selection issue

Postby ikam » Monday, 14.May 2012, 08:35

it's pushed... wait for update 8)

thks for analysis Skinnytorus
ikam
Operator
Operator
 
Posts: 911
Joined: Friday, 14.October 2011, 13:00
Location: France

Re: Extrude Op selection issue

Postby Skinnytorus » Monday, 14.May 2012, 09:05

Yay! Great many thank for that! Thumbs up!
Very interesting. I'll take a closer look at your changes later.
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Extrude Op selection issue

Postby Skinnytorus » Monday, 14.May 2012, 09:22

ikam
By the way, do your changes affect the demo player also? I mean, will the player 'understand' the changes in the right way?
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Extrude Op selection issue

Postby ikam » Monday, 14.May 2012, 09:38

the player use the same shared code. So yes it works with the demo player (just recompil it) :)
ikam
Operator
Operator
 
Posts: 911
Joined: Friday, 14.October 2011, 13:00
Location: France

Re: Extrude Op selection issue

Postby Skinnytorus » Monday, 14.May 2012, 09:51

Very nice. Thanks.
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46


Return to Support



Who is online

Users browsing this forum: No registered users and 16 guests

cron