44 |
|
void |
45 |
|
selectGroup(Scene *sc, const char *gname, int invert) |
46 |
|
{ |
47 |
< |
int gid = findName(gname, (const char **)sc->grpname, sc->ngrps); |
47 |
> |
int gid = getGroupID(sc, gname); |
48 |
|
Face *f; |
49 |
|
|
50 |
|
if (gid < 0) |
62 |
|
void |
63 |
|
selectMaterial(Scene *sc, const char *mname, int invert) |
64 |
|
{ |
65 |
< |
int mid = findName(mname, (const char **)sc->matname, sc->nmats); |
65 |
> |
int mid = getMaterialID(sc, mname); |
66 |
|
Face *f; |
67 |
|
|
68 |
|
if (mid < 0) |
180 |
|
int |
181 |
|
changeGroup(Scene *sc, const char *gname, int flreq, int flexc) |
182 |
|
{ |
183 |
< |
int grp = findName(gname, (const char **)sc->grpname, sc->ngrps); |
183 |
> |
int grp = getGroupID(sc, gname); |
184 |
|
if (grp < 0) { |
185 |
|
sc->grpname = chunk_alloc(char *, sc->grpname, sc->ngrps); |
186 |
|
sc->grpname[grp=sc->ngrps++] = savqstr((char *)gname); |
203 |
|
int |
204 |
|
changeMaterial(Scene *sc, const char *mname, int flreq, int flexc) |
205 |
|
{ |
206 |
< |
int mat = findName(mname, (const char **)sc->matname, sc->nmats); |
206 |
> |
int mat = getMaterialID(sc, mname); |
207 |
|
if (mat < 0) { |
208 |
|
sc->matname = chunk_alloc(char *, sc->matname, sc->nmats); |
209 |
|
sc->matname[mat=sc->nmats++] = savqstr((char *)mname); |
259 |
|
repl_tex[0] = -1; |
260 |
|
for (f = sc->vert[repl].vflist; f != NULL; f = f->v[j].fnext) { |
261 |
|
/* make sure prev isn't in there */ |
262 |
< |
for (j = 0; j < f->nv; j++) |
262 |
> |
for (j = f->nv; j-- > 0; ) |
263 |
|
if (f->v[j].vid == prev) |
264 |
|
return(0); |
265 |
< |
for (j = 0; j < f->nv; j++) |
265 |
> |
for (j = f->nv; j-- > 0; ) |
266 |
|
if (f->v[j].vid == repl) |
267 |
|
break; |
268 |
< |
if (j >= f->nv) |
268 |
> |
if (j < 0) |
269 |
|
goto linkerr; |
270 |
|
if (f->v[j].tid < 0) |
271 |
|
continue; |
290 |
|
/* get replacement normals */ |
291 |
|
repl_norm[0] = -1; |
292 |
|
for (f = sc->vert[repl].vflist; f != NULL; f = f->v[j].fnext) { |
293 |
< |
for (j = 0; j < f->nv; j++) |
293 |
> |
for (j = f->nv; j-- > 0; ) |
294 |
|
if (f->v[j].vid == repl) |
295 |
|
break; |
296 |
|
if (f->v[j].nid < 0) |
315 |
|
} |
316 |
|
/* replace occurrences of vertex */ |
317 |
|
for (f = sc->vert[prev].vflist; f != NULL; f = f->v[j].fnext) { |
318 |
< |
for (j = 0; j < f->nv; j++) |
318 |
> |
for (j = f->nv; j-- > 0; ) |
319 |
|
if (f->v[j].vid == prev) |
320 |
|
break; |
321 |
< |
if (j >= f->nv) |
321 |
> |
if (j < 0) |
322 |
|
goto linkerr; |
323 |
|
/* XXX doesn't allow for multiple references to prev in face */ |
324 |
|
f->v[j].vid = repl; /* replace vertex itself */ |
432 |
|
/* look for duplicates */ |
433 |
|
for (f1 = sc->vert[vid].vflist; f1 != NULL; |
434 |
|
f1 = f1->v[j].fnext) { |
435 |
< |
for (j = 0; j < f1->nv; j++) |
435 |
> |
for (j = f1->nv; j-- > 0; ) |
436 |
|
if (f1->v[j].vid == vid) |
437 |
|
break; |
438 |
< |
if (j >= f1->nv) |
438 |
> |
if (j < 0) |
439 |
|
break; /* missing link! */ |
440 |
|
if (f1 == f) |
441 |
|
continue; /* shouldn't happen */ |
488 |
|
continue; |
489 |
|
} |
490 |
|
while (vf != NULL) { |
491 |
< |
for (j = 0; j < vf->nv; j++) |
491 |
> |
for (j = vf->nv; j-- > 0; ) |
492 |
|
if (vf->v[j].vid == vid) |
493 |
|
break; |
494 |
< |
if (j >= vf->nv) |
494 |
> |
if (j < 0) |
495 |
|
break; /* error */ |
496 |
|
if (vf->v[j].fnext == ftst) { |
497 |
|
vf->v[j].fnext = |
588 |
|
for ( ; ; ) { /* else find position */ |
589 |
|
if (fp == f) |
590 |
|
return; /* already in list */ |
591 |
< |
for (j = 0; j < fp->nv; j++) |
591 |
> |
for (j = fp->nv; j-- > 0; ) |
592 |
|
if (fp->v[j].vid == vid) |
593 |
|
break; |
594 |
< |
if (j >= fp->nv) |
594 |
> |
if (j < 0) |
595 |
|
error(CONSISTENCY, "Link error in add2facelist()"); |
596 |
|
if (fp->v[j].fnext == NULL) |
597 |
|
break; /* reached the end */ |
654 |
|
void |
655 |
|
setGroup(Scene *sc, const char *nm) |
656 |
|
{ |
657 |
< |
sc->lastgrp = findName(nm, (const char **)sc->grpname, sc->ngrps); |
657 |
> |
sc->lastgrp = getGroupID(sc, nm); |
658 |
|
if (sc->lastgrp >= 0) |
659 |
|
return; |
660 |
|
sc->grpname = chunk_alloc(char *, sc->grpname, sc->ngrps); |
665 |
|
void |
666 |
|
setMaterial(Scene *sc, const char *nm) |
667 |
|
{ |
668 |
< |
sc->lastmat = findName(nm, (const char **)sc->matname, sc->nmats); |
668 |
> |
sc->lastmat = getMaterialID(sc, nm); |
669 |
|
if (sc->lastmat >= 0) |
670 |
|
return; |
671 |
|
sc->matname = chunk_alloc(char *, sc->matname, sc->nmats); |