Changeset 653


Ignore:
Timestamp:
04/20/17 21:06:47 (7 years ago)
Author:
Maciej Komosinski
Message:

Model::buildUsingSolidShapeTypes() can now handle single-Part models (affects SolidsShapeTypeModel?, ModelGeometryInfo?)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/model/model.cpp

    r644 r653  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2017  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    681681                // attach to part/joint
    682682                if (nu->part_refno >= 0)
     683                {
     684                        nu->attachToPart(nu->part_refno);
     685                        if (nu->part == NULL)
    683686                        {
    684                         nu->attachToPart(nu->part_refno);
    685                         if (nu->part==NULL)
    686                                 { error_message = SString::sprintf("Invalid reference to Part #%d", nu->part_refno); delete nu; return -1; }
     687                                error_message = SString::sprintf("Invalid reference to Part #%d", nu->part_refno); delete nu; return -1;
    687688                        }
     689                }
    688690                if (nu->joint_refno >= 0)
     691                {
     692                        nu->attachToJoint(nu->joint_refno);
     693                        if (nu->joint == NULL)
    689694                        {
    690                         nu->attachToJoint(nu->joint_refno);
    691                         if (nu->joint==NULL)
    692                                 { error_message = SString::sprintf("Invalid reference to Joint #%d", nu->joint_refno); delete nu; return -1; }
     695                                error_message = SString::sprintf("Invalid reference to Joint #%d", nu->joint_refno); delete nu; return -1;
    693696                        }
     697                }
    694698                if (srcrange) nu->setMapping(*srcrange);
    695699                // todo: check part/joint ref#
     
    13581362                p->scale.z = thickness;
    13591363        }
     1364        if (src_ballandstick_shapes.getJointCount() == 0) //single part "ball-and-stick" models are valid so let's make a valid solid shape model
     1365                for (int i = 0; i < src_ballandstick_shapes.getPartCount(); i++)
     1366                {
     1367                Part *op = src_ballandstick_shapes.getPart(i);
     1368                Part *p = addNewPart(Part::SHAPE_ELLIPSOID); //always using spherical shape regardless of the 'use_shape' parameter - 'use shape' is meant for sticks!
     1369                p->p = op->p;
     1370                p->rot = op->rot;
     1371                p->scale.x = p->scale.y = p->scale.z = thickness;
     1372                }
    13601373        for (int i = 0; i < src_ballandstick_shapes.getPartCount(); i++)
    13611374        {
Note: See TracChangeset for help on using the changeset viewer.