~ubuntu-branches/ubuntu/utopic/blender/utopic-proposed

« back to all changes in this revision

Viewing changes to intern/cycles/blender/blender_curves.cpp

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2011, Blender Foundation.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or
5
 
 * modify it under the terms of the GNU General Public License
6
 
 * as published by the Free Software Foundation; either version 2
7
 
 * of the License, or (at your option) any later version.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software Foundation,
16
 
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
2
 * Copyright 2011-2013 Blender Foundation
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 * http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License
17
15
 */
18
16
 
19
17
#include "attribute.h"
37
35
void interp_weights(float t, float data[4], int type);
38
36
float shaperadius(float shape, float root, float tip, float time);
39
37
void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyloc, float *time, ParticleCurveData *CData, int interpolation);
40
 
bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background, int uv_num);
41
 
bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background, int vcol_num);
42
 
bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background);
43
 
void ExportCurveSegments(Mesh *mesh, ParticleCurveData *CData, int interpolation, int segments);
44
 
void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, int interpolation, bool use_smooth, int segments, float3 RotCam);
45
 
void ExportCurveTriangleRibbons(Mesh *mesh, ParticleCurveData *CData, int interpolation, bool use_smooth, int segments);
46
 
void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int interpolation, bool use_smooth, int resolution, int segments);
47
 
void ExportCurveTriangleUV(Mesh *mesh, ParticleCurveData *CData, int interpolation, int segments, int vert_offset, int resol, float3 *uvdata);
48
 
void ExportCurveTriangleVcol(Mesh *mesh, ParticleCurveData *CData, int interpolation, int segments, int vert_offset, int resol, float3 *fdata);
 
38
bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int uv_num);
 
39
bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int vcol_num);
 
40
bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background);
 
41
void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData);
 
42
void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, float3 RotCam);
 
43
void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resolution);
 
44
void ExportCurveTriangleUV(Mesh *mesh, ParticleCurveData *CData, int vert_offset, int resol, float3 *uvdata);
 
45
void ExportCurveTriangleVcol(Mesh *mesh, ParticleCurveData *CData, int vert_offset, int resol, float3 *fdata);
49
46
 
50
47
ParticleCurveData::ParticleCurveData()
51
48
{
157
154
                curveinterp_v3_v3v3v3v3(keyloc, &ckey_loc1, &ckey_loc2, &ckey_loc3, &ckey_loc4, t);
158
155
}
159
156
 
160
 
bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background)
 
157
bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background)
161
158
{
162
159
 
163
160
        int curvenum = 0;
188
185
                                int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_psys.settings().draw_percentage() / 100.0f);
189
186
                                int totcurves = totchild;
190
187
                                
191
 
                                if(use_parents || b_psys.settings().child_type() == 0)
 
188
                                if(b_psys.settings().child_type() == 0)
192
189
                                        totcurves += totparts;
193
190
 
194
191
                                if(totcurves == 0)
208
205
                                CData->psys_closetip.push_back(get_boolean(cpsys, "use_closetip"));
209
206
 
210
207
                                int pa_no = 0;
211
 
                                if(!use_parents && !(b_psys.settings().child_type() == 0))
 
208
                                if(!(b_psys.settings().child_type() == 0))
212
209
                                        pa_no = totparts;
213
210
 
214
211
                                for(; pa_no < totparts+totchild; pa_no++) {
220
217
                                        float3 pcKey;
221
218
                                        for(int step_no = 0; step_no <= ren_step; step_no++) {
222
219
                                                float nco[3];
223
 
                                                b_psys.co_hair(*b_ob, psmd, pa_no, step_no, nco);
224
 
                                                float3 cKey = make_float3(nco[0],nco[1],nco[2]);
 
220
                                                b_psys.co_hair(*b_ob, pa_no, step_no, nco);
 
221
                                                float3 cKey = make_float3(nco[0], nco[1], nco[2]);
225
222
                                                cKey = transform_point(&itfm, cKey);
226
223
                                                if(step_no > 0)
227
224
                                                        curve_length += len(cKey - pcKey);
244
241
 
245
242
}
246
243
 
247
 
bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background, int uv_num)
 
244
bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int uv_num)
248
245
{
249
246
#if 0
250
247
        int keyno = 0;
279
276
                                int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_psys.settings().draw_percentage() / 100.0f);
280
277
                                int totcurves = totchild;
281
278
                                
282
 
                                if (use_parents || b_psys.settings().child_type() == 0)
 
279
                                if (b_psys.settings().child_type() == 0)
283
280
                                        totcurves += totparts;
284
281
 
285
282
                                if (totcurves == 0)
286
283
                                        continue;
287
284
 
288
285
                                int pa_no = 0;
289
 
                                if(!use_parents && !(b_psys.settings().child_type() == 0))
 
286
                                if(!(b_psys.settings().child_type() == 0))
290
287
                                        pa_no = totparts;
291
288
 
292
289
                                BL::ParticleSystem::particles_iterator b_pa;
315
312
 
316
313
}
317
314
 
318
 
bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background, int vcol_num)
 
315
bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int vcol_num)
319
316
{
320
317
#if 0
321
318
        int keyno = 0;
348
345
                                int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_psys.settings().draw_percentage() / 100.0f);
349
346
                                int totcurves = totchild;
350
347
                                
351
 
                                if (use_parents || b_psys.settings().child_type() == 0)
 
348
                                if (b_psys.settings().child_type() == 0)
352
349
                                        totcurves += totparts;
353
350
 
354
351
                                if (totcurves == 0)
355
352
                                        continue;
356
353
 
357
354
                                int pa_no = 0;
358
 
                                if(!use_parents && !(b_psys.settings().child_type() == 0))
 
355
                                if(!(b_psys.settings().child_type() == 0))
359
356
                                        pa_no = totparts;
360
357
 
361
358
                                BL::ParticleSystem::particles_iterator b_pa;
396
393
        }
397
394
}
398
395
 
399
 
void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, int interpolation, bool use_smooth, int segments, float3 RotCam)
 
396
void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, float3 RotCam)
400
397
{
401
398
        int vertexno = mesh->verts.size();
402
399
        int vertexindex = vertexno;
404
401
        for( int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
405
402
                for( int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
406
403
 
407
 
                        for( int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) {
408
 
 
409
 
                                int subv = 1;
410
 
                                float3 xbasis;
411
 
 
412
 
                                float3 v1;
413
 
 
414
 
                                if(curvekey == CData->curve_firstkey[curve]) {
415
 
                                        subv = 0;
416
 
                                        v1 = CData->curvekey_co[min(curvekey+2,CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1)] - CData->curvekey_co[curvekey];
417
 
                                }
418
 
                                else if(curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1)
419
 
                                        v1 = CData->curvekey_co[curvekey] - CData->curvekey_co[max(curvekey - 2, CData->curve_firstkey[curve])];
 
404
                        float3 xbasis;
 
405
                        float3 v1;
 
406
                        float time = 0.0f;
 
407
                        float3 ickey_loc = CData->curvekey_co[CData->curve_firstkey[curve]];
 
408
                        float radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], CData->psys_tipradius[sys], 0.0f);
 
409
                        v1 = CData->curvekey_co[CData->curve_firstkey[curve] + 1] - CData->curvekey_co[CData->curve_firstkey[curve]];
 
410
                        xbasis = normalize(cross(RotCam - ickey_loc,v1));
 
411
                        float3 ickey_loc_shfl = ickey_loc - radius * xbasis;
 
412
                        float3 ickey_loc_shfr = ickey_loc + radius * xbasis;
 
413
                        mesh->verts.push_back(ickey_loc_shfl);
 
414
                        mesh->verts.push_back(ickey_loc_shfr);
 
415
                        vertexindex += 2;
 
416
 
 
417
                        for( int curvekey = CData->curve_firstkey[curve] + 1; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve]; curvekey++) {
 
418
                                ickey_loc = CData->curvekey_co[curvekey];
 
419
 
 
420
                                if(curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1)
 
421
                                        v1 = CData->curvekey_co[curvekey] - CData->curvekey_co[max(curvekey - 1, CData->curve_firstkey[curve])];
420
422
                                else 
421
423
                                        v1 = CData->curvekey_co[curvekey + 1] - CData->curvekey_co[curvekey - 1];
422
424
 
423
 
 
424
 
                                for (; subv <= segments; subv++) {
425
 
 
426
 
                                        float3 ickey_loc = make_float3(0.0f,0.0f,0.0f);
427
 
                                        float time = 0.0f;
428
 
 
429
 
                                        if ((interpolation == CURVE_BSPLINE) && (curvekey == CData->curve_firstkey[curve]) && (subv == 0))
430
 
                                                ickey_loc = CData->curvekey_co[curvekey];
431
 
                                        else
432
 
                                                InterpolateKeySegments(subv, segments, curvekey, curve, &ickey_loc, &time, CData , interpolation);
433
 
 
434
 
                                        float radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], CData->psys_tipradius[sys], time);
435
 
 
436
 
                                        if((curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 2) && (subv == segments))
437
 
                                                radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], CData->psys_tipradius[sys], 0.95f);
438
 
 
439
 
                                        if(CData->psys_closetip[sys] && (subv == segments) && (curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 2))
440
 
                                                radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], 0.0f, 0.95f);
441
 
 
442
 
                                        xbasis = normalize(cross(RotCam - ickey_loc,v1));
443
 
                                        float3 ickey_loc_shfl = ickey_loc - radius * xbasis;
444
 
                                        float3 ickey_loc_shfr = ickey_loc + radius * xbasis;
445
 
                                        mesh->verts.push_back(ickey_loc_shfl);
446
 
                                        mesh->verts.push_back(ickey_loc_shfr);
447
 
                                        if(subv!=0) {
448
 
                                                mesh->add_triangle(vertexindex-2, vertexindex, vertexindex-1, CData->psys_shader[sys], use_smooth);
449
 
                                                mesh->add_triangle(vertexindex+1, vertexindex-1, vertexindex, CData->psys_shader[sys], use_smooth);
450
 
                                        }
451
 
                                        vertexindex += 2;
452
 
                                }
453
 
                        }
454
 
                }
455
 
        }
456
 
 
457
 
        mesh->reserve(mesh->verts.size(), mesh->triangles.size(), 0, 0);
458
 
        mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
459
 
        mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
460
 
        mesh->add_face_normals();
461
 
        mesh->add_vertex_normals();
462
 
        mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
463
 
 
464
 
        /* texture coords still needed */
465
 
}
466
 
 
467
 
void ExportCurveTriangleRibbons(Mesh *mesh, ParticleCurveData *CData, int interpolation, bool use_smooth, int segments)
468
 
{
469
 
        int vertexno = mesh->verts.size();
470
 
        int vertexindex = vertexno;
471
 
 
472
 
        for( int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
473
 
                for( int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
474
 
 
475
 
                        float3 firstxbasis = cross(make_float3(1.0f,0.0f,0.0f),CData->curvekey_co[CData->curve_firstkey[curve]+1] - CData->curvekey_co[CData->curve_firstkey[curve]]);
476
 
                        if(len_squared(firstxbasis)!= 0.0f)
477
 
                                firstxbasis = normalize(firstxbasis);
478
 
                        else
479
 
                                firstxbasis = normalize(cross(make_float3(0.0f,1.0f,0.0f),CData->curvekey_co[CData->curve_firstkey[curve]+1] - CData->curvekey_co[CData->curve_firstkey[curve]]));
480
 
 
481
 
                        for( int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) {
482
 
 
483
 
                                float3 xbasis = firstxbasis;
484
 
                                float3 v1;
485
 
                                float3 v2;
486
 
 
487
 
                                if(curvekey == CData->curve_firstkey[curve]) {
488
 
                                        v1 = CData->curvekey_co[min(curvekey+2,CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1)] - CData->curvekey_co[curvekey+1];
489
 
                                        v2 = CData->curvekey_co[curvekey+1] - CData->curvekey_co[curvekey];
490
 
                                }
491
 
                                else if(curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1) {
492
 
                                        v1 = CData->curvekey_co[curvekey] - CData->curvekey_co[curvekey-1];
493
 
                                        v2 = CData->curvekey_co[curvekey-1] - CData->curvekey_co[max(curvekey-2,CData->curve_firstkey[curve])];
494
 
                                }
495
 
                                else {
496
 
                                        v1 = CData->curvekey_co[curvekey+1] - CData->curvekey_co[curvekey];
497
 
                                        v2 = CData->curvekey_co[curvekey] - CData->curvekey_co[curvekey-1];
498
 
                                }
499
 
 
500
 
                                xbasis = cross(v1,v2);
501
 
 
502
 
                                if(len_squared(xbasis) >= 0.05f * len_squared(v1) * len_squared(v2)) {
503
 
                                        firstxbasis = normalize(xbasis);
504
 
                                        break;
505
 
                                }
506
 
                        }
507
 
 
508
 
                        for( int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) {
509
 
 
510
 
                                int subv = 1;
511
 
                                float3 v1;
512
 
                                float3 v2;
513
 
                                float3 xbasis;
514
 
 
515
 
                                if(curvekey == CData->curve_firstkey[curve]) {
516
 
                                        subv = 0;
517
 
                                        v1 = CData->curvekey_co[min(curvekey+2,CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1)] - CData->curvekey_co[curvekey+1];
518
 
                                        v2 = CData->curvekey_co[curvekey+1] - CData->curvekey_co[curvekey];
519
 
                                }
520
 
                                else if(curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1) {
521
 
                                        v1 = CData->curvekey_co[curvekey] - CData->curvekey_co[curvekey-1];
522
 
                                        v2 = CData->curvekey_co[curvekey-1] - CData->curvekey_co[max(curvekey-2,CData->curve_firstkey[curve])];
523
 
                                }
524
 
                                else {
525
 
                                        v1 = CData->curvekey_co[curvekey+1] - CData->curvekey_co[curvekey];
526
 
                                        v2 = CData->curvekey_co[curvekey] - CData->curvekey_co[curvekey-1];
527
 
                                }
528
 
 
529
 
                                xbasis = cross(v1,v2);
530
 
 
531
 
                                if(len_squared(xbasis) >= 0.05f * len_squared(v1) * len_squared(v2)) {
532
 
                                        xbasis = normalize(xbasis);
533
 
                                        firstxbasis = xbasis;
534
 
                                }
535
 
                                else
536
 
                                        xbasis = firstxbasis;
537
 
 
538
 
                                for (; subv <= segments; subv++) {
539
 
 
540
 
                                        float3 ickey_loc = make_float3(0.0f,0.0f,0.0f);
541
 
                                        float time = 0.0f;
542
 
 
543
 
                                        if ((interpolation == CURVE_BSPLINE) && (curvekey == CData->curve_firstkey[curve]) && (subv == 0))
544
 
                                                ickey_loc = CData->curvekey_co[curvekey];
545
 
                                        else
546
 
                                                InterpolateKeySegments(subv, segments, curvekey, curve, &ickey_loc, &time, CData , interpolation);
547
 
 
548
 
                                        float radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], CData->psys_tipradius[sys], time);
549
 
 
550
 
                                        if((curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 2) && (subv == segments))
551
 
                                                radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], CData->psys_tipradius[sys], 0.95f);
552
 
 
553
 
                                        if(CData->psys_closetip[sys] && (subv == segments) && (curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 2))
554
 
                                                radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], 0.0f, 0.95f);
555
 
 
556
 
                                        float3 ickey_loc_shfl = ickey_loc - radius * xbasis;
557
 
                                        float3 ickey_loc_shfr = ickey_loc + radius * xbasis;
558
 
                                        mesh->verts.push_back(ickey_loc_shfl);
559
 
                                        mesh->verts.push_back(ickey_loc_shfr);
560
 
                                        if(subv!=0) {
561
 
                                                mesh->add_triangle(vertexindex-2, vertexindex, vertexindex-1, CData->psys_shader[sys], use_smooth);
562
 
                                                mesh->add_triangle(vertexindex+1, vertexindex-1, vertexindex, CData->psys_shader[sys], use_smooth);
563
 
                                        }
564
 
                                        vertexindex += 2;
565
 
                                }
566
 
                        }
567
 
                }
568
 
        }
569
 
 
570
 
        mesh->reserve(mesh->verts.size(), mesh->triangles.size(), 0, 0);
571
 
        mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
572
 
        mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
573
 
        mesh->add_face_normals();
574
 
        mesh->add_vertex_normals();
575
 
        mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
576
 
        /* texture coords still needed */
577
 
 
578
 
}
579
 
 
580
 
void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int interpolation, bool use_smooth, int resolution, int segments)
 
425
                                time = CData->curvekey_time[curvekey]/CData->curve_length[curve];
 
426
                                radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], CData->psys_tipradius[sys], time);
 
427
 
 
428
                                if(curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1)
 
429
                                        radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], CData->psys_tipradius[sys], 0.95f);
 
430
 
 
431
                                if(CData->psys_closetip[sys] && (curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1))
 
432
                                        radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], 0.0f, 0.95f);
 
433
 
 
434
                                xbasis = normalize(cross(RotCam - ickey_loc,v1));
 
435
                                float3 ickey_loc_shfl = ickey_loc - radius * xbasis;
 
436
                                float3 ickey_loc_shfr = ickey_loc + radius * xbasis;
 
437
                                mesh->verts.push_back(ickey_loc_shfl);
 
438
                                mesh->verts.push_back(ickey_loc_shfr);
 
439
                                mesh->add_triangle(vertexindex-2, vertexindex, vertexindex-1, CData->psys_shader[sys], true);
 
440
                                mesh->add_triangle(vertexindex+1, vertexindex-1, vertexindex, CData->psys_shader[sys], true);
 
441
                                vertexindex += 2;
 
442
                        }
 
443
                }
 
444
        }
 
445
 
 
446
        mesh->reserve(mesh->verts.size(), mesh->triangles.size(), 0, 0);
 
447
        mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
 
448
        mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
 
449
        mesh->add_face_normals();
 
450
        mesh->add_vertex_normals();
 
451
        mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
 
452
 
 
453
        /* texture coords still needed */
 
454
}
 
455
 
 
456
void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resolution)
581
457
{
582
458
        int vertexno = mesh->verts.size();
583
459
        int vertexindex = vertexno;
652
528
 
653
529
                                ybasis = normalize(cross(xbasis,v2));
654
530
 
655
 
                                for (; subv <= segments; subv++) {
 
531
                                for (; subv <= 1; subv++) {
656
532
 
657
533
                                        float3 ickey_loc = make_float3(0.0f,0.0f,0.0f);
658
534
                                        float time = 0.0f;
659
535
 
660
 
                                        if ((interpolation == CURVE_BSPLINE) && (curvekey == CData->curve_firstkey[curve]) && (subv == 0))
661
 
                                                ickey_loc = CData->curvekey_co[curvekey];
662
 
                                        else
663
 
                                                InterpolateKeySegments(subv, segments, curvekey, curve, &ickey_loc, &time, CData , interpolation);
 
536
                                        InterpolateKeySegments(subv, 1, curvekey, curve, &ickey_loc, &time, CData , 1);
664
537
 
665
538
                                        float radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], CData->psys_tipradius[sys], time);
666
539
 
667
 
                                        if((curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 2) && (subv == segments))
 
540
                                        if((curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 2) && (subv == 1))
668
541
                                                radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], CData->psys_tipradius[sys], 0.95f);
669
542
 
670
 
                                        if(CData->psys_closetip[sys] && (subv == segments) && (curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 2))
 
543
                                        if(CData->psys_closetip[sys] && (subv == 1) && (curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 2))
671
544
                                                radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], 0.0f, 0.95f);
672
545
 
673
546
                                        float angle = M_2PI_F / (float)resolution;
678
551
 
679
552
                                        if(subv!=0) {
680
553
                                                for(int section = 0 ; section < resolution - 1; section++) {
681
 
                                                        mesh->add_triangle(vertexindex - resolution + section, vertexindex + section, vertexindex - resolution + section + 1, CData->psys_shader[sys], use_smooth);
682
 
                                                        mesh->add_triangle(vertexindex + section + 1, vertexindex - resolution + section + 1, vertexindex + section, CData->psys_shader[sys], use_smooth);
 
554
                                                        mesh->add_triangle(vertexindex - resolution + section, vertexindex + section, vertexindex - resolution + section + 1, CData->psys_shader[sys], true);
 
555
                                                        mesh->add_triangle(vertexindex + section + 1, vertexindex - resolution + section + 1, vertexindex + section, CData->psys_shader[sys], true);
683
556
                                                }
684
 
                                                mesh->add_triangle(vertexindex-1, vertexindex + resolution - 1, vertexindex - resolution, CData->psys_shader[sys], use_smooth);
685
 
                                                mesh->add_triangle(vertexindex, vertexindex - resolution , vertexindex + resolution - 1, CData->psys_shader[sys], use_smooth);
 
557
                                                mesh->add_triangle(vertexindex-1, vertexindex + resolution - 1, vertexindex - resolution, CData->psys_shader[sys], true);
 
558
                                                mesh->add_triangle(vertexindex, vertexindex - resolution , vertexindex + resolution - 1, CData->psys_shader[sys], true);
686
559
                                        }
687
560
                                        vertexindex += resolution;
688
561
                                }
700
573
        /* texture coords still needed */
701
574
}
702
575
 
703
 
static void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData, int interpolation, int segments)
 
576
void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData)
704
577
{
705
578
        int num_keys = 0;
706
579
        int num_curves = 0;
725
598
 
726
599
                        size_t num_curve_keys = 0;
727
600
 
728
 
                        for( int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) {
729
 
 
730
 
                                int subv = 1;
731
 
                                if(curvekey == CData->curve_firstkey[curve])
732
 
                                        subv = 0;
733
 
 
734
 
                                for (; subv <= segments; subv++) {
735
 
 
736
 
                                        float3 ickey_loc = make_float3(0.0f,0.0f,0.0f);
737
 
                                        float time = 0.0f;
738
 
 
739
 
                                        if((interpolation == CURVE_BSPLINE) && (curvekey == CData->curve_firstkey[curve]) && (subv == 0))
740
 
                                                ickey_loc = CData->curvekey_co[curvekey];
741
 
                                        else
742
 
                                                InterpolateKeySegments(subv, segments, curvekey, curve, &ickey_loc, &time, CData , interpolation);
743
 
 
744
 
                                        float radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], CData->psys_tipradius[sys], time);
745
 
 
746
 
                                        if(CData->psys_closetip[sys] && (subv == segments) && (curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 2))
747
 
                                                radius =0.0f;
748
 
 
749
 
                                        mesh->add_curve_key(ickey_loc, radius);
750
 
                                        if(attr_intercept)
751
 
                                                attr_intercept->add(time);
752
 
 
753
 
                                        num_curve_keys++;
754
 
                                }
 
601
                        for( int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve]; curvekey++) {
 
602
                                float3 ickey_loc = CData->curvekey_co[curvekey];
 
603
                                float time = CData->curvekey_time[curvekey]/CData->curve_length[curve];
 
604
                                float radius = shaperadius(CData->psys_shape[sys], CData->psys_rootradius[sys], CData->psys_tipradius[sys], time);
 
605
 
 
606
                                if(CData->psys_closetip[sys] && (curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1))
 
607
                                        radius =0.0f;
 
608
 
 
609
                                mesh->add_curve_key(ickey_loc, radius);
 
610
                                if(attr_intercept)
 
611
                                        attr_intercept->add(time);
 
612
 
 
613
                                num_curve_keys++;
755
614
                        }
756
615
 
757
616
                        mesh->add_curve(num_keys, num_curve_keys, CData->psys_shader[sys]);
769
628
        }
770
629
}
771
630
 
772
 
void ExportCurveTriangleUV(Mesh *mesh, ParticleCurveData *CData, int interpolation, int segments, int vert_offset, int resol, float3 *uvdata)
 
631
void ExportCurveTriangleUV(Mesh *mesh, ParticleCurveData *CData, int vert_offset, int resol, float3 *uvdata)
773
632
{
774
633
        if(uvdata == NULL)
775
634
                return;
784
643
 
785
644
                        for( int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) {
786
645
 
787
 
                                int subv = 1;
788
 
 
789
 
                                if (curvekey == CData->curve_firstkey[curve])
790
 
                                        subv = 0;
 
646
                                time = CData->curvekey_time[curvekey]/CData->curve_length[curve];
 
647
 
 
648
                                for(int section = 0 ; section < resol; section++) {
 
649
                                        uvdata[vertexindex] = CData->curve_uv[curve];
 
650
                                        uvdata[vertexindex].z = prevtime;
 
651
                                        vertexindex++;
 
652
                                        uvdata[vertexindex] = CData->curve_uv[curve];
 
653
                                        uvdata[vertexindex].z = time;
 
654
                                        vertexindex++;
 
655
                                        uvdata[vertexindex] = CData->curve_uv[curve];
 
656
                                        uvdata[vertexindex].z = prevtime;
 
657
                                        vertexindex++;
 
658
                                        uvdata[vertexindex] = CData->curve_uv[curve];
 
659
                                        uvdata[vertexindex].z = time;
 
660
                                        vertexindex++;
 
661
                                        uvdata[vertexindex] = CData->curve_uv[curve];
 
662
                                        uvdata[vertexindex].z = prevtime;
 
663
                                        vertexindex++;
 
664
                                        uvdata[vertexindex] = CData->curve_uv[curve];
 
665
                                        uvdata[vertexindex].z = time;
 
666
                                        vertexindex++;
 
667
                                }
 
668
 
 
669
                                prevtime = time;                        
791
670
                                
792
 
                                for (; subv <= segments; subv++) {
793
 
 
794
 
                                        float3 ickey_loc = make_float3(0.0f,0.0f,0.0f);
795
 
 
796
 
                                        InterpolateKeySegments(subv, segments, curvekey, curve, &ickey_loc, &time, CData , interpolation);
797
 
 
798
 
                                        if(subv!=0) {
799
 
                                                for(int section = 0 ; section < resol; section++) {
800
 
                                                        uvdata[vertexindex] = CData->curve_uv[curve];
801
 
                                                        uvdata[vertexindex].z = prevtime;
802
 
                                                        vertexindex++;
803
 
                                                        uvdata[vertexindex] = CData->curve_uv[curve];
804
 
                                                        uvdata[vertexindex].z = time;
805
 
                                                        vertexindex++;
806
 
                                                        uvdata[vertexindex] = CData->curve_uv[curve];
807
 
                                                        uvdata[vertexindex].z = prevtime;
808
 
                                                        vertexindex++;
809
 
                                                        uvdata[vertexindex] = CData->curve_uv[curve];
810
 
                                                        uvdata[vertexindex].z = time;
811
 
                                                        vertexindex++;
812
 
                                                        uvdata[vertexindex] = CData->curve_uv[curve];
813
 
                                                        uvdata[vertexindex].z = prevtime;
814
 
                                                        vertexindex++;
815
 
                                                        uvdata[vertexindex] = CData->curve_uv[curve];
816
 
                                                        uvdata[vertexindex].z = time;
817
 
                                                        vertexindex++;
818
 
                                                }
819
 
                                        }
820
 
 
821
 
                                        prevtime = time;
822
 
                                }
823
671
                        }
824
672
                }
825
673
        }
826
674
 
827
675
}
828
676
 
829
 
void ExportCurveTriangleVcol(Mesh *mesh, ParticleCurveData *CData, int interpolation, int segments, int vert_offset, int resol, float3 *fdata)
 
677
void ExportCurveTriangleVcol(Mesh *mesh, ParticleCurveData *CData, int vert_offset, int resol, float3 *fdata)
830
678
{
831
679
        if(fdata == NULL)
832
680
                return;
833
681
 
834
 
        float time = 0.0f;
835
 
//      float prevtime = 0.0f; // UNUSED
836
 
 
837
682
        int vertexindex = vert_offset;
838
683
 
839
684
        for( int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
841
686
 
842
687
                        for( int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) {
843
688
 
844
 
                                int subv = 1;
845
 
 
846
 
                                if (curvekey == CData->curve_firstkey[curve])
847
 
                                        subv = 0;
848
 
                                
849
 
                                for (; subv <= segments; subv++) {
850
 
 
851
 
                                        float3 ickey_loc = make_float3(0.0f,0.0f,0.0f);
852
 
 
853
 
                                        InterpolateKeySegments(subv, segments, curvekey, curve, &ickey_loc, &time, CData , interpolation);
854
 
 
855
 
                                        if(subv!=0) {
856
 
                                                for(int section = 0 ; section < resol; section++) {
857
 
                                                        fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]);
858
 
                                                        vertexindex++;
859
 
                                                        fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]);
860
 
                                                        vertexindex++;
861
 
                                                        fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]);
862
 
                                                        vertexindex++;
863
 
                                                        fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]);
864
 
                                                        vertexindex++;
865
 
                                                        fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]);
866
 
                                                        vertexindex++;
867
 
                                                        fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]);
868
 
                                                        vertexindex++;
869
 
                                                }
870
 
                                        }
871
 
 
872
 
                                        // prevtime = time;  // UNUSED
 
689
                                for(int section = 0 ; section < resol; section++) {
 
690
                                        fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]);
 
691
                                        vertexindex++;
 
692
                                        fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]);
 
693
                                        vertexindex++;
 
694
                                        fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]);
 
695
                                        vertexindex++;
 
696
                                        fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]);
 
697
                                        vertexindex++;
 
698
                                        fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]);
 
699
                                        vertexindex++;
 
700
                                        fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]);
 
701
                                        vertexindex++;
873
702
                                }
874
703
                        }
875
704
                }
882
711
void BlenderSync::sync_curve_settings()
883
712
{
884
713
        PointerRNA csscene = RNA_pointer_get(&b_scene.ptr, "cycles_curves");
885
 
        
886
 
        int preset = get_enum(csscene, "preset");
887
714
 
888
715
        CurveSystemManager *curve_system_manager = scene->curve_system_manager;
889
716
        CurveSystemManager prev_curve_system_manager = *curve_system_manager;
892
719
        curve_system_manager->minimum_width = get_float(csscene, "minimum_width");
893
720
        curve_system_manager->maximum_width = get_float(csscene, "maximum_width");
894
721
 
895
 
        if(preset == CURVE_CUSTOM) {
896
 
                /*custom properties*/
897
 
                curve_system_manager->primitive = get_enum(csscene, "primitive");
898
 
                curve_system_manager->line_method = get_enum(csscene, "line_method");
899
 
                curve_system_manager->interpolation = get_enum(csscene, "interpolation");
900
 
                curve_system_manager->triangle_method = get_enum(csscene, "triangle_method");
901
 
                curve_system_manager->resolution = get_int(csscene, "resolution");
902
 
                curve_system_manager->segments = get_int(csscene, "segments");
903
 
                curve_system_manager->use_smooth = get_boolean(csscene, "use_smooth");
904
 
                curve_system_manager->subdivisions = get_int(csscene, "subdivisions");
905
 
 
906
 
                curve_system_manager->normalmix = get_float(csscene, "normalmix");
907
 
                curve_system_manager->encasing_ratio = get_float(csscene, "encasing_ratio");
908
 
 
909
 
                curve_system_manager->use_parents = get_boolean(csscene, "use_parents");
910
 
                curve_system_manager->use_encasing = get_boolean(csscene, "use_encasing");
911
 
                curve_system_manager->use_backfacing = get_boolean(csscene, "use_backfacing");
912
 
                curve_system_manager->use_joined = get_boolean(csscene, "use_joined");
913
 
                curve_system_manager->use_tangent_normal = get_boolean(csscene, "use_tangent_normal");
914
 
                curve_system_manager->use_tangent_normal_geometry = get_boolean(csscene, "use_tangent_normal_geometry");
915
 
                curve_system_manager->use_tangent_normal_correction = get_boolean(csscene, "use_tangent_normal_correction");
916
 
        }
917
 
        else {
918
 
                curve_system_manager->primitive = CURVE_LINE_SEGMENTS;
919
 
                curve_system_manager->interpolation = CURVE_CARDINAL;
920
 
                curve_system_manager->normalmix = 1.0f;
921
 
                curve_system_manager->encasing_ratio = 1.01f;
922
 
                curve_system_manager->use_parents = false;
923
 
                curve_system_manager->segments = 1;
924
 
                curve_system_manager->use_joined = false;
925
 
 
926
 
                switch(preset) {
927
 
                        case CURVE_FAST_PLANES:
928
 
                                /*camera facing planes*/
929
 
                                curve_system_manager->primitive = CURVE_TRIANGLES;
930
 
                                curve_system_manager->triangle_method = CURVE_CAMERA_TRIANGLES;
931
 
                                curve_system_manager->use_smooth = true;
932
 
                                curve_system_manager->resolution = 1;
933
 
                                break;
934
 
                        case CURVE_TANGENT_SHADING:
935
 
                                /*tangent shading*/
936
 
                                curve_system_manager->line_method = CURVE_UNCORRECTED;
937
 
                                curve_system_manager->use_encasing = true;
938
 
                                curve_system_manager->use_backfacing = false;
939
 
                                curve_system_manager->use_tangent_normal = true;
940
 
                                curve_system_manager->use_tangent_normal_geometry = true;
941
 
                                curve_system_manager->use_tangent_normal_correction = false;
942
 
                                break;
943
 
                        case CURVE_TRUE_NORMAL:
944
 
                                /*True Normal*/
945
 
                                curve_system_manager->line_method = CURVE_CORRECTED;
946
 
                                curve_system_manager->use_encasing = true;
947
 
                                curve_system_manager->use_backfacing = false;
948
 
                                curve_system_manager->use_tangent_normal = false;
949
 
                                curve_system_manager->use_tangent_normal_geometry = false;
950
 
                                curve_system_manager->use_tangent_normal_correction = false;
951
 
                                break;
952
 
                        case CURVE_ACCURATE_PRESET:
953
 
                                /*Accurate*/
954
 
                                curve_system_manager->line_method = CURVE_ACCURATE;
955
 
                                curve_system_manager->use_encasing = false;
956
 
                                curve_system_manager->use_backfacing = true;
957
 
                                curve_system_manager->use_tangent_normal = false;
958
 
                                curve_system_manager->use_tangent_normal_geometry = false;
959
 
                                curve_system_manager->use_tangent_normal_correction = false;
960
 
                                break;
961
 
                        case CURVE_SMOOTH_CURVES:
962
 
                                /*Cardinal curves preset*/
963
 
                                curve_system_manager->primitive = CURVE_SEGMENTS;
964
 
                                curve_system_manager->use_backfacing = true;
965
 
                                curve_system_manager->subdivisions = 4;
966
 
                                break;
967
 
                        case CURVE_SMOOTH_RIBBONS:
968
 
                                /*Cardinal ribbons preset*/
969
 
                                curve_system_manager->primitive = CURVE_RIBBONS;
970
 
                                curve_system_manager->use_backfacing = false;
971
 
                                curve_system_manager->subdivisions = 4;
972
 
                                break;
973
 
                }
974
 
                
 
722
        curve_system_manager->primitive = get_enum(csscene, "primitive");
 
723
        curve_system_manager->curve_shape = get_enum(csscene, "shape");
 
724
        curve_system_manager->resolution = get_int(csscene, "resolution");
 
725
        curve_system_manager->subdivisions = get_int(csscene, "subdivisions");
 
726
        curve_system_manager->use_backfacing = !get_boolean(csscene, "cull_backfacing");
 
727
 
 
728
        curve_system_manager->encasing_ratio = 1.01f;
 
729
 
 
730
        if(curve_system_manager->primitive == CURVE_TRIANGLES && curve_system_manager->curve_shape == CURVE_RIBBON) {
 
731
                /*camera facing planes*/
 
732
                curve_system_manager->triangle_method = CURVE_CAMERA_TRIANGLES;
 
733
                curve_system_manager->resolution = 1;
 
734
        }
 
735
        if(curve_system_manager->primitive == CURVE_TRIANGLES && curve_system_manager->curve_shape == CURVE_THICK) {
 
736
                /*camera facing planes*/
 
737
                curve_system_manager->triangle_method = CURVE_TESSELATED_TRIANGLES;
 
738
        }
 
739
        if(curve_system_manager->primitive == CURVE_LINE_SEGMENTS && curve_system_manager->curve_shape == CURVE_RIBBON) {
 
740
                /*tangent shading*/
 
741
                curve_system_manager->line_method = CURVE_UNCORRECTED;
 
742
                curve_system_manager->use_encasing = true;
 
743
                curve_system_manager->use_backfacing = false;
 
744
                curve_system_manager->use_tangent_normal = true;
 
745
                curve_system_manager->use_tangent_normal_geometry = true;
 
746
        }
 
747
        if(curve_system_manager->primitive == CURVE_LINE_SEGMENTS && curve_system_manager->curve_shape == CURVE_THICK) {
 
748
                curve_system_manager->line_method = CURVE_ACCURATE;
 
749
                curve_system_manager->use_encasing = false;
 
750
                curve_system_manager->use_tangent_normal = false;
 
751
                curve_system_manager->use_tangent_normal_geometry = false;
 
752
        }
 
753
        if(curve_system_manager->primitive == CURVE_SEGMENTS && curve_system_manager->curve_shape == CURVE_RIBBON) {
 
754
                curve_system_manager->primitive = CURVE_RIBBONS;
 
755
                curve_system_manager->use_backfacing = false;
975
756
        }
976
757
 
977
758
        if(curve_system_manager->modified_mesh(prev_curve_system_manager))
1013
794
        }
1014
795
 
1015
796
        int primitive = scene->curve_system_manager->primitive;
1016
 
        int interpolation = scene->curve_system_manager->interpolation;
1017
797
        int triangle_method = scene->curve_system_manager->triangle_method;
1018
798
        int resolution = scene->curve_system_manager->resolution;
1019
 
        int segments = scene->curve_system_manager->segments;
1020
 
        bool use_smooth = scene->curve_system_manager->use_smooth;
1021
 
        bool use_parents = scene->curve_system_manager->use_parents;
1022
 
        bool export_tgs = scene->curve_system_manager->use_joined;
1023
799
        size_t vert_num = mesh->verts.size();
1024
800
        size_t tri_num = mesh->triangles.size();
1025
801
        int used_res = 1;
1031
807
        if(!preview)
1032
808
                set_resolution(mesh, &b_mesh, &b_ob, &b_scene, true);
1033
809
 
1034
 
        ObtainCacheParticleData(mesh, &b_mesh, &b_ob, &CData, use_parents, !preview);
 
810
        ObtainCacheParticleData(mesh, &b_mesh, &b_ob, &CData, !preview);
1035
811
 
1036
812
        /* obtain camera parameters */
1037
813
        BL::Object b_CamOb = b_scene.camera();
1044
820
        }
1045
821
 
1046
822
        /* add hair geometry to mesh */
1047
 
        if(primitive == CURVE_TRIANGLES){
 
823
        if(primitive == CURVE_TRIANGLES) {
1048
824
                if(triangle_method == CURVE_CAMERA_TRIANGLES)
1049
 
                        ExportCurveTrianglePlanes(mesh, &CData, interpolation, use_smooth, segments, RotCam);
1050
 
                else if(triangle_method == CURVE_RIBBON_TRIANGLES)
1051
 
                        ExportCurveTriangleRibbons(mesh, &CData, interpolation, use_smooth, segments);
 
825
                        ExportCurveTrianglePlanes(mesh, &CData, RotCam);
1052
826
                else {
1053
 
                        ExportCurveTriangleGeometry(mesh, &CData, interpolation, use_smooth, resolution, segments);
 
827
                        ExportCurveTriangleGeometry(mesh, &CData, resolution);
1054
828
                        used_res = resolution;
1055
829
                }
1056
830
        }
1057
831
        else {
1058
 
                ExportCurveSegments(scene, mesh, &CData, interpolation, segments);
1059
 
                int ckey_num = mesh->curve_keys.size();
1060
 
 
1061
 
                /*export tangents or curve data? - not functional yet*/
1062
 
                if(export_tgs && ckey_num > 1) {
1063
 
                        Attribute *attr_tangent = mesh->curve_attributes.add(ATTR_STD_CURVE_TANGENT);
1064
 
                        float3 *data_tangent = attr_tangent->data_float3();
1065
 
                        
1066
 
                        for(int ck = 0; ck < ckey_num; ck++) {
1067
 
                                float3 tg = normalize(normalize(mesh->curve_keys[min(ck + 1, ckey_num - 1)].co - mesh->curve_keys[ck].co) -
1068
 
                                        normalize(mesh->curve_keys[max(ck - 1, 0)].co - mesh->curve_keys[ck].co));
1069
 
                                
1070
 
                                data_tangent[ck] = tg;
1071
 
                        }
1072
 
                }
 
832
                ExportCurveSegments(scene, mesh, &CData);
1073
833
        }
1074
834
 
1075
835
 
1109
869
                        if(!mesh->need_attribute(scene, ustring(l->name().c_str())))
1110
870
                                continue;
1111
871
 
1112
 
                        ObtainCacheParticleVcol(mesh, &b_mesh, &b_ob, &CData, use_parents, !preview, vcol_num);
 
872
                        ObtainCacheParticleVcol(mesh, &b_mesh, &b_ob, &CData, !preview, vcol_num);
1113
873
 
1114
874
                        if(primitive == CURVE_TRIANGLES) {
1115
875
 
1118
878
 
1119
879
                                float3 *fdata = attr_vcol->data_float3();
1120
880
 
1121
 
                                ExportCurveTriangleVcol(mesh, &CData, interpolation, segments, tri_num * 3, used_res, fdata);
 
881
                                ExportCurveTriangleVcol(mesh, &CData, tri_num * 3, used_res, fdata);
1122
882
                        }
1123
883
                        else {
1124
884
                                Attribute *attr_vcol = mesh->curve_attributes.add(
1148
908
                        if(mesh->need_attribute(scene, name) || mesh->need_attribute(scene, std)) {
1149
909
                                Attribute *attr_uv;
1150
910
 
1151
 
                                ObtainCacheParticleUV(mesh, &b_mesh, &b_ob, &CData, use_parents, !preview, uv_num);
 
911
                                ObtainCacheParticleUV(mesh, &b_mesh, &b_ob, &CData, !preview, uv_num);
1152
912
 
1153
913
                                if(primitive == CURVE_TRIANGLES) {
1154
914
                                        if(active_render)
1158
918
 
1159
919
                                        float3 *uv = attr_uv->data_float3();
1160
920
 
1161
 
                                        ExportCurveTriangleUV(mesh, &CData, interpolation, segments, tri_num * 3, used_res, uv);
 
921
                                        ExportCurveTriangleUV(mesh, &CData, tri_num * 3, used_res, uv);
1162
922
                                }
1163
923
                                else {
1164
924
                                        if(active_render)