Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007896opensim[REGION] Script Functionspublic2016-04-27 14:032017-11-23 12:20
ReporterMata Hari 
Assigned ToDiva 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformIntel i7 930 quadOSWindows .NETOS VersionWin10 x64
Product Versionmaster (dev code) 
Target VersionFixed in Version 
Summary0007896: PRIM_TYPE reports incorrectly when flexi-prim is enabled
DescriptionIf you make a prim flexible, it incorrectly reports itself as being a cube even when it isn't. This creates problems for a variety of scripted objects such as the advanced inter-active loop rez tool which needs to accurately know (and set) a prim's type and flexi settings.
Steps To ReproduceRez a cylinder

Add this script to it:
default
{
    touch_start(integer num)
    {
        llSay(0, llDumpList2String(llGetPrimitiveParams([PRIM_TYPE]),"|"));
    }
}

Touch the prim: it will report itself as type 1 (a cylinder)

Enable flexible path on the cylinder and touch again. It will now report itself as being type 0 (a cube)

If you deactivate flexible path again, it will resume reporting itself as a cylinder.
Additional InformationI have tested this and found it occurs with both 0.8.2 and 0.9 (both Bullet and ODE).
TagsNo tags attached.
Git Revision or version number
Run Mode Grid (Multiple Regions per Sim)
Physics EngineOther
Script Engine
Environment.NET / Windows64
Mono VersionNone
Viewer
Attached Filespatch file icon 0001-Detection-of-Cylinder-and-Prism-for-flexi-prims.patch [^] (1,871 bytes) 2016-05-27 20:36 [Show Content]

- Relationships
related to 0007910new Setting PRIM_FLEXIBLE with llSetPrimitiveParams corrupts PRIM_TYPE 

-  Notes
(0030266)
Mata Hari (reporter)
2016-05-03 08:02

Probably related to this same bug, if a prim has a shape that cannot be made flexible and you send a script command that sets the boolean value of the flex parameter to FALSE, it will result in very bizarre change to the prim's type. This shouldn't happen.

To reproduce:

- Rez a sphere
- Add this script to it

default
{
    touch_start(integer num)
    {
        llSetPrimitiveParams([PRIM_FLEXIBLE,0,0,1.0,0.2,0.2,0.2,<0,0,0>]);
    }
}

Then touch the prim...it will suddenly transform itself into a "Line-> Half Circle"
(0030357)
Mandarinka Tasty (reporter)
2016-05-22 05:32
edited on: 2016-05-22 06:29

Hello !

The problem of getting and setting PRIM_TYPE in case of Flexi prims refers to

situaiton how Flexi prims have been defined.

This thing:

part.Shape.PathCurve = (byte)Extrusion.Flexible; enables flexibiltiy of the prim

and this:

part.Shape.PathCurve = (byte)Extrusion.Straight; disables it


Unfortunately when we want to get type of prim, the code uses procedure:

public PrimType GetPrimType()
        {
            if (Shape.SculptEntry)
                return PrimType.SCULPT;
            
            if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Square)
            {
                if (Shape.PathCurve == (byte)Extrusion.Straight)
                    return PrimType.BOX;
                else if (Shape.PathCurve == (byte)Extrusion.Curve1)
                    return PrimType.TUBE;
            }
            else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
            {
                if (Shape.PathCurve == (byte)Extrusion.Straight)
                    return PrimType.CYLINDER;
                // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits
                else if (Shape.PathCurve == (byte)Extrusion.Curve1)
                    return PrimType.TORUS;
            }
            else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
            {
                if (Shape.PathCurve == (byte)Extrusion.Curve1 || Shape.PathCurve == (byte)Extrusion.Curve2)
                    return PrimType.SPHERE;
            }
            else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
            {
                if (Shape.PathCurve == (byte)Extrusion.Straight)
                    return PrimType.PRISM;
                else if (Shape.PathCurve == (byte)Extrusion.Curve1)
                    return PrimType.RING;
            }

            return PrimType.BOX;
        }

And because

public enum Extrusion : byte
    {
        Straight = 16,
        Curve1 = 32,
        Curve2 = 48,
        Flexible = 128
    }

We can see, in this way, that flexibility has been defined in such parallel way to other situations: Straight, Curve1, Curve2.

And now OpenSim when it comes to (byte)Extrusion.Flexible

thinks that Flexi is other type of the prim and returns return PrimType.BOX; !!!

Because opensim knows how to classify the prim for cases: straight, curve1 , curve2 but does not know what to do if Flexible.

And because enum Extrusion defines all 4 situations in parallel way, then

for actual opensim, it is not possibel to accept situation: Straight and flexi in same time, or curve1 and flexi in same time.

Addionally all info is stored in database in PathCurve field.

That makes problem even more complexed to cure.

Mayeb there should be created other field in primshapes table: like PathFlexi ?

It would help to make being flexi independent of enum Extrusion.

Unfortunately public enum ExtraParamType has no access to these parts of code, where it could help, either

(0030364)
Seth Nygard (reporter)
2016-05-22 08:10

If I look at the code above it appears that the original intention was to mask bits0-6 and test for prim type, while preserving bit 7 which is the Flexible bit.

When setting or changing the prim type, rather than explicitly setting the prim type to a single value, it should be also masked with the Flexible bit to ensure the expected behavior is achieved.

If we do this then it is possible to a value to (Straight | Flexible) which preserves the Flexible bit as well as the Straight extrusion type, while simply setting it to Straight would set it as Straight and non Flexible.

Therefore the code sections that test/set the PathCurve values need to be modified to properly handle the Flexible bit. This should be a relatively easy fix.
(0030365)
Mandarinka Tasty (reporter)
2016-05-22 13:58
edited on: 2016-05-22 14:07

Hello again :)

Thank You Seth, yes you're right in this context, referring to masking bits.

I confess, I'm still learning the C# and was not understanding clearly this

notification: Shape.ProfileCurve & 0x07 But You have helped me to get it. Ty :)

Anyway I have used my logics and first at all I have reminded that,

only three types of prims are flexiable: Box, Cylinder and Prism.

That means, we do not need to worry about any testing and referring to other types of prims in aspect of getting type of prims.

So , because Box and Cylinder and Prism belong to three various categories:

I. Box is considered under (byte)ProfileShape.Square

II. Cylinder is considered under: (byte)ProfileShape.Circle

III. Prims is considered under: (byte)ProfileShape.EquilateralTriangle


then such situation makes solution of the problem much easier.

Frist case : Box. We do not need to worry at all, because end of

public PrimType GetPrimType() returns PrimType.BOX

So detection of flexible Box=Cube works always.


Next:

Cylinder is categorised here:

else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
            {
                if (Shape.PathCurve == (byte)Extrusion.Straight)
                    return PrimType.CYLINDER;
                else if (Shape.PathCurve == (byte)Extrusion.Curve1)
                    return PrimType.TORUS;
            }

and Prism here:

else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
            {
                if (Shape.PathCurve == (byte)Extrusion.Straight)
                    return PrimType.PRISM;
                else if (Shape.PathCurve == (byte)Extrusion.Curve1)
                    return PrimType.RING;
            }

So it is absolutely enough to feed those two categories with:

testing against: (byte)Extrusion.Flexible

Because they are under diffeernt Profile.Shape,

we are safe = there won't be problem with precise detection.

So my solution is ( in SceneObjectPart.cs ):

else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
            {
                if (Shape.PathCurve == (byte)Extrusion.Straight)
                    return PrimType.CYLINDER;
                else if (Shape.PathCurve == (byte)Extrusion.Curve1)
                    return PrimType.TORUS;
                else if (Shape.PathCurve == (byte)Extrusion.Flexible)
                    return PrimType.CYLINDER;
            }


and

else if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
            {
                if (Shape.PathCurve == (byte)Extrusion.Straight)
                    return PrimType.PRISM;
                else if (Shape.PathCurve == (byte)Extrusion.Curve1)
                    return PrimType.RING;
                else if (Shape.PathCurve == (byte)Extrusion.Flexible)
                    return PrimType.PRISM;
            }

And that works. I have compiled: opensim-0.9.0-312-g057d1b2 against my solution and

simple LSL code:

default
{
    touch_start(integer num)
    {
        llOwnerSay((string)llGetPrimitiveParams([PRIM_TYPE]));
    }
}

correctly shows PRIM_TYPE, with flexi on and flexi off.

Other prim types like: Tube, Torus, Ring, we do not need to worry, because

they can't be set as flexi in the viewer: they are not flexiable.

Let someone test it and confirm =verify it.

Regards

(0030464)
Diva (administrator)
2016-06-12 14:03

Patch applied.

[14:02] <cia-opensim> opensim: mandarinka.tasty * r634d85a30d2b OpenSim/Region/Framework/Scenes (SceneObjectPart.cs):
[14:02] <cia-opensim> Detection of Cylinder and Prism for flexi prims
[14:02] <cia-opensim>
[14:02] <cia-opensim> Signed-off-by: Mandarinka Tasty <mandarinka.tasty@gmail.com>
[14:02] <cia-opensim> Signed-off-by: Diva Canto <diva@metaverseink.com>
(0030553)
Diva (administrator)
2016-06-17 12:18

Is this fixed?
(0030554)
Mandarinka Tasty (reporter)
2016-06-17 12:19

yes, here it is fixed.
(0030555)
Mandarinka Tasty (reporter)
2016-06-17 12:32

Box, Cylinder and Prism correctly report their type, after setting them manually

to be flexible, via the viewer's edit tool.

And other type of prims are not considered under this situaiton, because:

only box, cylinder and prism can be set as flexible via the viewer.
(0030562)
JeffKelley (reporter)
2016-06-18 06:07
edited on: 2016-06-18 06:07

default {
    touch_start(integer num) {
        list l = llGetPrimitiveParams([PRIM_TYPE]);
        llShout (0, (string) llList2Integer (l,0) );
    }
}


Commit d0c65d1


Set type to box + flexi
[05:56] MANTIS 7896 shouts: 0

Set type to cylinder + flexi
[05:56] MANTIS 7896 shouts: 1

Set type to prism + flexi
[05:57] MANTIS 7896 shouts: 2


Seems fixed.

(0030564)
Diva (administrator)
2016-06-18 08:43

As per reported

- Issue History
Date Modified Username Field Change
2016-04-27 14:03 Mata Hari New Issue
2016-05-03 08:02 Mata Hari Note Added: 0030266
2016-05-20 13:35 Mata Hari Relationship added related to 0007910
2016-05-22 05:17 Mandarinka Tasty Note Added: 0030355
2016-05-22 05:17 Mandarinka Tasty Note Deleted: 0030355
2016-05-22 05:32 Mandarinka Tasty Note Added: 0030357
2016-05-22 06:29 Mandarinka Tasty Note Edited: 0030357 View Revisions
2016-05-22 08:10 Seth Nygard Note Added: 0030364
2016-05-22 13:58 Mandarinka Tasty Note Added: 0030365
2016-05-22 13:59 Mandarinka Tasty Note Edited: 0030365 View Revisions
2016-05-22 14:00 Mandarinka Tasty Note Edited: 0030365 View Revisions
2016-05-22 14:07 Mandarinka Tasty Note Edited: 0030365 View Revisions
2016-05-26 19:36 Mandarinka Tasty File Added: 0001-Detection-for-CYLINDER-and-PRISM-for-flexi-prims.patch
2016-05-26 19:37 Mandarinka Tasty Status new => patch included
2016-05-27 20:35 Mandarinka Tasty File Deleted: 0001-Detection-for-CYLINDER-and-PRISM-for-flexi-prims.patch
2016-05-27 20:36 Mandarinka Tasty File Added: 0001-Detection-of-Cylinder-and-Prism-for-flexi-prims.patch
2016-06-12 14:03 Diva Note Added: 0030464
2016-06-17 12:18 Diva Note Added: 0030553
2016-06-17 12:19 Mandarinka Tasty Note Added: 0030554
2016-06-17 12:32 Mandarinka Tasty Note Added: 0030555
2016-06-18 06:07 JeffKelley Note Added: 0030562
2016-06-18 06:07 JeffKelley Note Edited: 0030562 View Revisions
2016-06-18 06:07 JeffKelley Note Edited: 0030562 View Revisions
2016-06-18 08:43 Diva Note Added: 0030564
2016-06-18 08:43 Diva Status patch included => resolved
2016-06-18 08:43 Diva Resolution open => fixed
2016-06-18 08:43 Diva Assigned To => Diva
2017-11-23 12:20 Mata Hari Status resolved => closed


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker