Example #1
0
/* both pointers should exist */
static void copy_texture_space(Object *to, Object *ob)
{
	float *poin1= NULL, *poin2= NULL;
	short texflag= 0;
	
	if (ob->type==OB_MESH) {
		texflag= ((Mesh *)ob->data)->texflag;
		poin2= ((Mesh *)ob->data)->loc;
	}
	else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
		texflag= ((Curve *)ob->data)->texflag;
		poin2= ((Curve *)ob->data)->loc;
	}
	else if (ob->type==OB_MBALL) {
		texflag= ((MetaBall *)ob->data)->texflag;
		poin2= ((MetaBall *)ob->data)->loc;
	}
	else
		return;
		
	if (to->type==OB_MESH) {
		((Mesh *)to->data)->texflag= texflag;
		poin1= ((Mesh *)to->data)->loc;
	}
	else if (ELEM3(to->type, OB_CURVE, OB_SURF, OB_FONT)) {
		((Curve *)to->data)->texflag= texflag;
		poin1= ((Curve *)to->data)->loc;
	}
	else if (to->type==OB_MBALL) {
		((MetaBall *)to->data)->texflag= texflag;
		poin1= ((MetaBall *)to->data)->loc;
	}
	else
		return;
	
	memcpy(poin1, poin2, 9*sizeof(float));	/* this was noted in DNA_mesh, curve, mball */
	
	if (to->type==OB_MESH) {
		/* pass */
	}
	else if (to->type == OB_MBALL) {
		tex_space_mball(to);
	}
	else {
		tex_space_curve(to->data);
	}
	
}
Example #2
0
void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
	DerivedMesh **derivedFinal, int forRender, int forOrco)
{
	ListBase *nubase;
	Nurb *nu;
	Curve *cu = ob->data;
	DispList *dl;
	float *data;
	int len;
	int numVerts;
	float (*originalVerts)[3];
	float (*deformedVerts)[3];

	if(!forRender && cu->editnurb)
		nubase= ED_curve_editnurbs(cu);
	else
		nubase= &cu->nurb;

	if(!forOrco)
		curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts);

	for (nu=nubase->first; nu; nu=nu->next) {
		if(forRender || nu->hide==0) {
			int resolu= nu->resolu, resolv= nu->resolv;

			if(forRender){
				if(cu->resolu_ren) resolu= cu->resolu_ren;
				if(cu->resolv_ren) resolv= cu->resolv_ren;
			}

			if(nu->pntsv==1) {
				len= SEGMENTSU(nu)*resolu;

				dl= MEM_callocN(sizeof(DispList), "makeDispListsurf");
				dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts");

				BLI_addtail(dispbase, dl);
				dl->parts= 1;
				dl->nr= len;
				dl->col= nu->mat_nr;
				dl->charidx= nu->charidx;

				/* dl->rt will be used as flag for render face and */
				/* CU_2D conflicts with R_NOPUNOFLIP */
				dl->rt= nu->flag & ~CU_2D;

				data= dl->verts;
				if(nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
				else dl->type= DL_SEGM;

				makeNurbcurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float));
			}
			else {
				len= (nu->pntsu*resolu) * (nu->pntsv*resolv);
				
				dl= MEM_callocN(sizeof(DispList), "makeDispListsurf");
				dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts");
				BLI_addtail(dispbase, dl);

				dl->col= nu->mat_nr;
				dl->charidx= nu->charidx;

				/* dl->rt will be used as flag for render face and */
				/* CU_2D conflicts with R_NOPUNOFLIP */
				dl->rt= nu->flag & ~CU_2D;

				data= dl->verts;
				dl->type= DL_SURF;

				dl->parts= (nu->pntsu*resolu);	/* in reverse, because makeNurbfaces works that way */
				dl->nr= (nu->pntsv*resolv);
				if(nu->flagv & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_U;	/* reverse too! */
				if(nu->flagu & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_V;

				makeNurbfaces(nu, data, 0, resolu, resolv);
				
				/* gl array drawing: using indices */
				displist_surf_indices(dl);
			}
		}
	}

	/* make copy of 'undeformed" displist for texture space calculation
	   actually, it's not totally undeformed -- pre-tesselation modifiers are
	   already applied, thats how it worked for years, so keep for compatibility (sergey) */
	copy_displist(&cu->disp, dispbase);

	if (!forRender) {
		tex_space_curve(cu);
	}

	if(!forOrco)
		curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal,
			forRender, originalVerts, deformedVerts);
}