Changeset 825 for cpp/frams/vm/classes


Ignore:
Timestamp:
11/25/18 20:10:31 (5 years ago)
Author:
Maciej Komosinski
Message:

Simplified XYZ.toString() and made Orient.toString() use our official number-formatting function

Location:
cpp/frams/vm/classes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/vm/classes/3dobject.cpp

    r343 r825  
    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-2018  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    9393}
    9494
     95SString Pt3D_Ext::toString() const
     96{
     97        SString s = "(";
     98        s += SString::valueOf(p.x);
     99        s += ",";
     100        s += SString::valueOf(p.y);
     101        s += ",";
     102        s += SString::valueOf(p.z);
     103        s += ")";
     104        return s;
     105}
     106
    95107void Pt3D_Ext::get_toString(ExtValue *ret)
    96108{
    97         SString s = "(";
    98         ExtValue v;
    99         v.setDouble(p.x); s += v.getString();
    100         s += ",";
    101         v.setDouble(p.y); s += v.getString();
    102         s += ",";
    103         v.setDouble(p.z); s += v.getString();
    104         s += ")";
    105         ret->setString(s);
     109        ret->setString(toString());
    106110}
    107111
     
    174178{
    175179        int index = args->getInt();
    176         if ((index < 0) || (index>2))
     180        if ((index < 0) || (index > 2))
    177181                ret->setEmpty();
    178182        else
     
    184188#ifdef __CODEGUARD__
    185189        static Pt3D_Ext static_pt3dobj;
    186         static Param static_pt3dparam(getStaticParamtab(),&static_pt3dobj);
     190        static Param static_pt3dparam(getStaticParamtab(), &static_pt3dobj);
    187191#else
    188192        static Param static_pt3dparam(getStaticParamtab());
     
    378382        {
    379383                double q1 = args[0].getDouble(), q2 = 1.0 - q1;
    380                 o.x.x = q1*o1->o.x.x + q2*o2->o.x.x;
    381                 o.x.y = q1*o1->o.x.y + q2*o2->o.x.y;
    382                 o.x.z = q1*o1->o.x.z + q2*o2->o.x.z;
    383                 o.y.x = q1*o1->o.y.x + q2*o2->o.y.x;
    384                 o.y.y = q1*o1->o.y.y + q2*o2->o.y.y;
    385                 o.y.z = q1*o1->o.y.z + q2*o2->o.y.z;
    386                 o.z.x = q1*o1->o.z.x + q2*o2->o.z.x;
    387                 o.z.y = q1*o1->o.z.y + q2*o2->o.z.y;
    388                 o.z.z = q1*o1->o.z.z + q2*o2->o.z.z;
     384                o.x.x = q1 * o1->o.x.x + q2 * o2->o.x.x;
     385                o.x.y = q1 * o1->o.x.y + q2 * o2->o.x.y;
     386                o.x.z = q1 * o1->o.x.z + q2 * o2->o.x.z;
     387                o.y.x = q1 * o1->o.y.x + q2 * o2->o.y.x;
     388                o.y.y = q1 * o1->o.y.y + q2 * o2->o.y.y;
     389                o.y.z = q1 * o1->o.y.z + q2 * o2->o.y.z;
     390                o.z.x = q1 * o1->o.z.x + q2 * o2->o.z.x;
     391                o.z.y = q1 * o1->o.z.y + q2 * o2->o.z.y;
     392                o.z.z = q1 * o1->o.z.z + q2 * o2->o.z.z;
    389393                o.normalize();
    390394        }
     
    399403        {
    400404                double q1 = args[0].getDouble(), q2 = 1.0 - q1;
    401                 o.x.x = q1*o1->o.x.x + q2*p2->p.x;
    402                 o.x.y = q1*o1->o.x.y + q2*p2->p.y;
    403                 o.x.z = q1*o1->o.x.z + q2*p2->p.z;
     405                o.x.x = q1 * o1->o.x.x + q2 * p2->p.x;
     406                o.x.y = q1 * o1->o.x.y + q2 * p2->p.y;
     407                o.x.z = q1 * o1->o.x.z + q2 * p2->p.z;
    404408                o.normalize();
    405409        }
     
    448452void Orient_Ext::get_toString(ExtValue *ret)
    449453{
    450         Pt3D a = o.getAngles();
    451         ret->setString(SString::sprintf("Orient@(%g,%g,%g)", a.x, a.y, a.z));
     454        Pt3D_Ext a(o.getAngles());
     455        ret->setString(SString("Orient@") + a.toString());
    452456}
    453457
     
    456460#ifdef __CODEGUARD__
    457461        static Orient_Ext static_orientobj;
    458         static Param static_orientparam(getStaticParamtab(),&static_orientobj);
     462        static Param static_orientparam(getStaticParamtab(), &static_orientobj);
    459463#else
    460464        static Param static_orientparam(getStaticParamtab());
  • cpp/frams/vm/classes/3dobject.h

    r343 r825  
    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-2018  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    3434        PARAMPROCDEF(p_get);
    3535#undef STATRICKCLASS
    36 
     36        SString toString() const;
    3737        static ParamInterface* getInterface();
    3838        static ExtObject makeStaticObject(Pt3D* p);
Note: See TracChangeset for help on using the changeset viewer.