RCTools 4.3

User avatar
rray
Moderator
Posts: 1575
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: RCTools 4.3

Post by rray » 14 Apr 2011, 22:50

You're all welcome!
Now would be a good time to start the "rray (re)coding community project",
to get rid of the c# (and let others do all the work! :D )
I'm in! No... wait 8-}
"as a maya discussion grows longer, the probability of a suggestion involving deleting the preferences approaches one"

softimage resources section (formerly known as rray.de/xsi) updated May 30 2018

User avatar
Hirazi Blue
Administrator
Posts: 4918
Joined: 04 Jun 2009, 12:15

Re: RCTools 4.3

Post by Hirazi Blue » 15 Apr 2011, 10:31

rray wrote:I'm in! No... wait 8-}
=))
(but the initial idea was meant to be taken more or less seriously ;) )
...

User avatar
rray
Moderator
Posts: 1575
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: RCTools 4.3

Post by rray » 15 Apr 2011, 15:17

:-bd source code available here. (rctools4_cs directory) Will be of assistance :-B
"as a maya discussion grows longer, the probability of a suggestion involving deleting the preferences approaches one"

softimage resources section (formerly known as rray.de/xsi) updated May 30 2018

User avatar
Hirazi Blue
Administrator
Posts: 4918
Joined: 04 Jun 2009, 12:15

Re: RCTools 4.3

Post by Hirazi Blue » 15 Apr 2011, 16:32

To Python? (no guarantees, obviously, that's the downside of open source... :D )
...

User avatar
rray
Moderator
Posts: 1575
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: RCTools 4.3

Post by rray » 15 Apr 2011, 16:45

Can't tell you what would actually run the fastest (which would probably be a big decision factor) - I'll do some tests.

Python would "sort of" make sense because I'm planing to use XPOP3 (written in python) for the popup (instead of the C++ MFC version)
"as a maya discussion grows longer, the probability of a suggestion involving deleting the preferences approaches one"

softimage resources section (formerly known as rray.de/xsi) updated May 30 2018

User avatar
Hirazi Blue
Administrator
Posts: 4918
Joined: 04 Jun 2009, 12:15

Re: RCTools 4.3

Post by Hirazi Blue » 15 Apr 2011, 16:56

I hope you decide on Python, otherwise I'd have to step down as a volunteer... ;)
...

User avatar
rray
Moderator
Posts: 1575
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: RCTools 4.3

Post by rray » 17 Apr 2011, 14:54

Oh no x_x Python performs 30 times slower than JS in my tests.

I've written a simple triangle filter
(sources python/JS/VBS below -- For testing I used a polymsh sphere, local subd refinement, Doo-Sabin, Level 4)

Python Output:
# Execution time : 3388.01209812 ms
JS Output:
# INFO : Execution time : 113 ms
VBS Output:
' INFO : Execution Time = 93,75 ms
Maybe it's the way I use the for loop in python that's wrong .. no idea @-)

C++ test still to go...

btw (from RCTools):

C# Output:
// INFO : Execution time : 576 ms

Code: Select all

import win32com.client

# Import the constants 
from win32com.client import constants
from time import *

null = None
false = 0
true = 1

def XSILoadPlugin( in_reg ):
	in_reg.Author = "Ray"
	in_reg.Name = "PyBench Plug-in"
	in_reg.Major = 1
	in_reg.Minor = 0

	in_reg.RegisterFilter("PyBench", constants.siFilterSubComponentPolygon)
	#RegistrationInsertionPoint - do not remove this line

	return true
 
def XSIUnloadPlugin( in_reg ):
	strPluginName = in_reg.Name
	Application.LogMessage(str(strPluginName) + str(" has been unloaded."),constants.siVerbose)
	return true

# Match callback for the PyBench custom filter.
def PyBench_Match( in_ctxt ):
	Application.LogMessage("PyBench_Match called", constants.siVerbose)

# 	Return value indicates if the input object matches the filter criterias.
	return true

# Subset callback for the PyBench custom filter. 
def PyBench_Subset( in_ctxt ):
	Application.LogMessage("PyBench_Subset called", constants.siVerbose)

	start = clock()
	
	items = []	
	coll = XSIFactory.CreateObject("XSI.Collection")
	in_objs = in_ctxt.GetAttribute("Input")
	 
	for obj in in_objs:
		subc = obj.SubComponent
		cc = subc.ComponentCollection			

		for poly in cc: 
			if poly.Points.Count < 4:
				items.append(poly.Index)	
				
		oGeo = subc.Parent3DObject.ActivePrimitive.GetGeometry2( 0, constants.siConstructionModeSecondaryShape )
		coll.Add( oGeo.CreateSubComponent("poly", items) )
		 
	in_ctxt.SetAttribute("Output", coll) 
	
	end = clock()
	print("Execution time : " + str(1000*(end - start)) + " ms")
	
	return true

# Init callback for the PyBench custom filter.
def PyBench_Init( in_ctxt ):
	Application.LogMessage("PyBench_Init called", constants.siVerbose)

	return true

Code: Select all

function XSILoadPlugin( in_reg )
{ 
	in_reg.Author =  "Ray";
	in_reg.Name = "JSBench Plug-in";
	in_reg.Major = 1;
	in_reg.Minor = 0;

	in_reg.RegisterFilter("JSBench",siFilterSubComponentPolygon);
	//RegistrationInsertionPoint - do not remove this line

	return true;
}

function XSIUnloadPlugin( in_reg )
{
	var strPluginName;
	strPluginName = in_reg.Name;
	Application.LogMessage(strPluginName + " has been unloaded.",siVerbose);
	return true;
}

// Match callback for the JSBench custom filter.
function JSBench_Match( in_ctxt )
{
	Application.LogMessage("JSBench_Match called",siVerbose);

// 	Return value indicates if the input object matches the filter criterias.
	return true;
}

// Subset callback for the JSBench custom filter.
function JSBench_Subset( in_ctxt )
{
	Application.LogMessage("JSBench_Subset called");
	
	var start = new Date().getTime();
	   
	coll = new ActiveXObject("XSI.Collection");
	
	in_objs = in_ctxt.GetAttribute("Input");
	
	jsA = new Array();

	e = new Enumerator(in_objs);
	for(; !e.atEnd(); e.moveNext()) 
	{
		logmessage(e.item().type);
		subc = e.item().SubComponent;
		cc = subc.ComponentCollection;

		e2 = new Enumerator(cc);		
		for(; !e2.atEnd(); e2.moveNext()) {
			if(e2.item().Points.Count < 4)
				jsA.push(e2.item().Index);
		}
	
		oGeo = subc.Parent3DObject.ActivePrimitive.GetGeometry(0, siConstructionMode.siConstructionModeSecondaryShape);
		coll.Add( oGeo.CreateSubComponent("poly", jsA) );
	}

	in_ctxt.SetAttribute("Output", coll);
	
	var end = new Date().getTime();
	logmessage("Execution time : " + eval(end - start) + " ms");
	
// 	Return value indicates if a subset of the input objects matches the filter criterias.
	return true;
}

// Init callback for the JSBench custom filter.
function JSBench_Init( in_ctxt )
{
	Application.LogMessage("JSBench_Init called",siVerbose);

	return true;
}

Code: Select all

function XSILoadPlugin( in_reg )
	in_reg.Author = "Ray"
	in_reg.Name = "VBBench Plug-in"
	in_reg.Major = 1
	in_reg.Minor = 0

	in_reg.RegisterFilter "VBBench",siFilterSubComponentPolygon
	'RegistrationInsertionPoint - do not remove this line

	XSILoadPlugin = true
end function

function XSIUnloadPlugin( in_reg )
	dim strPluginName
	strPluginName = in_reg.Name
	Application.LogMessage strPluginName & " has been unloaded.",siVerbose
	XSIUnloadPlugin = true
end function

' Match callback for the VBBench custom filter.
function VBBench_Match( in_ctxt )
	Application.LogMessage "VBBench_Match called",siVerbose	
	
' 	Return value indicates if the input object matches the filter criterias.
	VBBench_Match = true
end function

' Subset callback for the VBBench custom filter.
function VBBench_Subset( in_ctxt )
	Application.LogMessage "VBBench_Subset called",siVerbose

	start = timer
   
	set coll = CreateObject( "XSI.Collection" )
	
	set in_objects = in_ctxt.GetAttribute( "Input" )

	for each obj in in_objects
		' get the edge object(s) from the subcomponent
		set subc = obj.SubComponent

		dim aIndices
		nb_indices = 0
		
		l_Array = subc.ElementArray 
		set l_Comps = subc.ComponentCollection
		
		ReDim aIndices( ubound(l_Array) - lbound(l_Array) )
		
		for each ply in l_Comps
			if ply.Points.Count < 4 then
				aIndices(nb_indices) = ply.Index
				nb_indices = nb_indices + 1		
			end if
		next
		
		if nb_indices > 0 then
			ReDim Preserve aIndices( nb_indices - 1 )
			set oSubComponent = subc.Parent3DObject.activeprimitive.geometry.CreateSubComponent("poly", aIndices )
			coll.Add oSubComponent
		end if	
	next
	
	in_ctxt.SetAttribute "Output", coll

	endt = timer
	
	LogMessage "Execution Time = " & 1000*(endt-start) & " ms"

	VBBench_Subset = coll.Count > 04
end function

' Init callback for the VBBench custom filter.
function VBBench_Init( in_ctxt )
	Application.LogMessage "VBBench_Init called",siVerbose

	VBBench_Init = true
end function
"as a maya discussion grows longer, the probability of a suggestion involving deleting the preferences approaches one"

softimage resources section (formerly known as rray.de/xsi) updated May 30 2018

User avatar
rray
Moderator
Posts: 1575
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: RCTools 4.3

Post by rray » 20 Apr 2011, 00:20

Well ok I looks like I won't be able to get python to perform any faster with this - I guess I'm going to do aport to VBS then - seems not like too much work except changing some syntax.

VBS seems the closest to Softimage's internal architecture. JScript probably is, too (COM Version) except the arrays are different and some translation there has to be done which makes it a little slower than VBS.
"as a maya discussion grows longer, the probability of a suggestion involving deleting the preferences approaches one"

softimage resources section (formerly known as rray.de/xsi) updated May 30 2018

j3st3r
Posts: 121
Joined: 11 Jun 2009, 09:13

Re: RCTools 4.3

Post by j3st3r » 20 Apr 2011, 10:30

Python's loops seems to be lot slower in Softimage than the others...

User avatar
Hirazi Blue
Administrator
Posts: 4918
Joined: 04 Jun 2009, 12:15

Re: RCTools 4.3

Post by Hirazi Blue » 08 May 2011, 11:09

Moderator edit: I moved the announcement for RCTools 4.4 to a new thread
...

iamVFX
Posts: 697
Joined: 24 Sep 2010, 18:28

Re: RCTools 4.3

Post by iamVFX » 17 Oct 2012, 21:43

rray wrote:Oh no x_x Python performs 30 times slower than JS in my tests.

I've written a simple triangle filter
(sources python/JS/VBS below -- For testing I used a polymsh sphere, local subd refinement, Doo-Sabin, Level 4)

Python Output:
# Execution time : 3388.01209812 ms
ROFL

Python is not slow, it's fucking Microsoft COM converting list to COM VARIANT so long for some reason (remove list conversion at the end and you'll see):

Code: Select all

import win32com.client

from win32com.client import constants as c
from time import *

start = clock()

coll = XSIFactory.CreateObject("XSI.Collection")

obj = Application.Selection(0)

subc = obj.SubComponent
cc = subc.ComponentCollection          

items = (poly.Index for poly in cc if poly.Points.Count < 4)

end = clock()
print("Execution time : " + str(1000*(end - start)) + " ms") 

oGeo = subc.Parent3DObject.ActivePrimitive.GetGeometry2( 0, c.siConstructionModeSecondaryShape )
coll.Add( oGeo.CreateSubComponent("poly", list(items)) )
[rimg=800]http://img855.imageshack.us/img855/3231/eba39e090eb24256963b3b3.png[/rimg]