XM Magdalena 3D print, GGeorgy (3D)
LC #42 Pipers Alley

View Full Version : Weird bug with custom objects update

10-20-2010, 06:40 PM
Hello everyone. I've been working on a maxscript level editor, and recently I needed to add an attribute to a custom object. No problem I thought... until I found a very weird problem.

First, here is a short overview of my custom object:

global attWall = attributes exportAttributesWall
attribID:#(0x1CE1CE, 0x1CE000)
parameters paramsWall
objectType type:#integer default:g_objTypeWall
objectId type:#integer default:g_objIdSurfaceNormal
height type:#float default:1.0
length type:#float default:1.0
width type:#float default:1.0
isAnimated type:#boolean default:false
isCollision type:#boolean default:false
isCamStopper type:#boolean default:false

plugin simpleObject SBWall
classID:#(0xC05703, 0x1CE000)

parameters paramsWall rollout:roWall
objectId type:#integer ui:uiDDL_ObjectId default:g_objIdSurfaceNormal
height type:#float ui:uiSPNHeight default:1.0
length type:#float ui:uiSPNLength default:1.0
width type:#float ui:uiSPNWidth default:1.0
isAnimated type:#boolean ui:uiCBXAnimated default:false
isCollision type:#boolean ui:uiCBXCollision default:false
isCamStopper type:#boolean ui:uiCBXCamStopper default:false


rollout roWall "Wall Parameters" width:162 height:142
spinner uiSPNLength "Length" pos:[9, 15] width:120 height:16 range:[1,999999,1]
spinner uiSPNWidth "Width" pos:[9, 38] width:120 height:16 range:[1,999999,1]
spinner uiSPNHeight "Height" pos:[9, 61] width:120 height:16 range:[1,999999,1]
dropdownList uiDDL_ObjectId "Type" pos:[9, 81] width:136 height:40 items:gSURFACE_NAMES
checkbox uiCBXAnimated "Animated" pos:[9,125] width:140 height:20 enabled:true checked:false
checkbox uiCBXCollision "No physics" pos:[9,150] width:140 height:20 enabled:true checked:false
checkbox uiCBXCamStopper "Stops Camera Movement" pos:[9,175] width:140 height:20 enabled:true checked:false


on buildMesh do
display = createInstance box width:width length:length height:height
mesh = display.mesh

on update do
this.exportAttributesWall.isAnimated.controller = this.isAnimated.controller = bezier_float()
this.exportAttributesWall.isCollision.controller = this.isCollision.controller = bezier_float()

if( (isProperty this.exportAttributesWall "isCamStopper") == false) then
[...] this is where the interesting stuff happens[...]

on create do
custAttributes.add this attWall

this.exportAttributesWall.objectId.controller = this.objectId.controller = bezier_float()
this.exportAttributesWall.height.controller = this.height.controller = bezier_float()
this.exportAttributesWall.length.controller = this.length.controller = bezier_float()
this.exportAttributesWall.width.controller = this.width.controller = bezier_float()
this.exportAttributesWall.isAnimated.controller = this.isAnimated.controller = bezier_float()
this.exportAttributesWall.isCollision.controller = this.isCollision.controller = bezier_float()
this.exportAttributesWall.isCamStopper.controller = this.isCamStopper.controller = bezier_float()

So, the new attribute is "isCamStopper". I added it to the custom attributes I use for exporting (attWall), as well as to the params of my object, and i added a checkbox to my ui to change it.

In my on Update callback, I link the value from the custom attribute, to the object's attributes (this is necessary since our exporter only exports the custom attributes).

Now The twisted part is, I loaded a couple of old levels, to see if things would be updated properly, and most of the times, they are... except for a couple of objects. For some reason, some of them pop an error saying isCamStopper is not an attribute of exportAttributesWall. So after some fiddling around, I printed out the attributes of attWall. On the objects that correctly updated, attWall listed all the values as expected. On the objects that did not update correctly, attWall had all attributes, except the one I recently added (isCamStopper).

My first guess was that somehow at somepoint I gave some objects the wrong class ID. but printing out classIDs showed me all objects, wether they updated correctly or not, had the same class ID. The only difference seems that some of them see the new attribute in attWall, and some don't.

Am I just missing something? Could anyone explain to me why some of my old objects are having trouble being updated? Is there a solution I could use to add said attribute to those troublesome objects?

10-20-2010, 07:58 PM
Half found my own answer. The custom objects that caused a problem were objects on which the user did a "turn to editable poly".

I still would appreciate an explanation on the deeper cause of that bug.

CGTalk Moderation
10-20-2010, 07:58 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.